File: suite_suite_test.go

package info (click to toggle)
golang-ginkgo 1.16.5-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,004 kB
  • sloc: sh: 14; makefile: 7
file content (51 lines) | stat: -rw-r--r-- 1,055 bytes parent folder | download | duplicates (3)
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
}