Can Ginkgo It blocks be put inside a for loop? I have a table of test cases (a slice of structs) which I'd like to iterate through:
var _ = Describe("...", func() {
var testcases = []struct{
startState string
endState string
}{
{"start", "stop"},
{"stop", "start"},
}
for i := range testcases {
tc := testcases[i]
It("...", func() {
// Run test case
})
}
})
This compiles and runs but it runs just the last test case multiple times. Is this expected behaviour?
I can put the for loop inside the It block and it works as expected but then I can't use BeforeEach (since there's only one It block) and it can be difficult to work out which test case is failing.