1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
package suite_test
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
var dynamicallyGeneratedTests = []string{}
func Test(t *testing.T) {
RegisterFailHandler(Fail)
dynamicallyGeneratedTests = []string{"Test A", "Test B", "Test C"}
RunSpecs(t, "Suite")
}
var numBeforeSuiteRuns = 0
var numAfterSuiteRuns = 0
var numDynamicallyGeneratedTests = 0
var _ = BeforeSuite(func() {
numBeforeSuiteRuns++
})
var _ = AfterSuite(func() {
numAfterSuiteRuns++
Ω(numBeforeSuiteRuns).Should(Equal(1))
Ω(numAfterSuiteRuns).Should(Equal(1))
Ω(numDynamicallyGeneratedTests).Should(Equal(3), "Expected three test to be dynamically generated")
})
var _ = Describe("Top-level cotnainer node lifecycle", func() {
for _, test := range dynamicallyGeneratedTests {
numDynamicallyGeneratedTests += 1
It(fmt.Sprintf("runs dynamically generated test: %s", test), func() {
Ω(true).Should(BeTrue())
})
}
})
//Fakes
type fakeTestingT struct {
didFail bool
}
func (fakeT *fakeTestingT) Fail() {
fakeT.didFail = true
}
|