Skip to content

Commit db3c5ce

Browse files
authored
Merge pull request #253 from pohly/register-multiple-times
sanity: support embedding tests multiple time in Ginkgo
2 parents 8f687ee + ddf8b3f commit db3c5ce

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/sanity/sanity.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ func Test(t GinkgoTestingT, config TestConfig) {
231231
// GinkgoTest for use when the tests run. Therefore its content can
232232
// still be modified in a BeforeEach. The sanity package itself treats
233233
// it as read-only.
234+
//
235+
// Only tests defined with DescribeSanity after the last invocation with
236+
// GinkgoTest (if there has be one) will be added, i.e. each test only
237+
// gets added at most once.
234238
func GinkgoTest(config *TestConfig) *TestContext {
235239
sc := newTestContext(config)
236240
registerTestsInGinkgo(sc)

pkg/sanity/tests.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,8 @@ func registerTestsInGinkgo(sc *TestContext) {
5353
})
5454
})
5555
}
56+
// Don't register tests more than once! More tests might
57+
// be added later in a different context, followed by
58+
// another registerTestsInGinkgo call.
59+
tests = nil
5660
}

0 commit comments

Comments
 (0)