Closed RedCrazyGhost closed 2 weeks ago
Hi @RedCrazyGhost there's a section in the docs about this: https://onsi.github.io/ginkgo/#dynamically-generating-specs
My guess is that you've hit a common Go gotcha relating to variables in loops; more details here: https://go.dev/blog/loopvar-preview
A couple of things to try are to copy c
as suggested in the docs:
for _, c := range cases {
c := c
Context(c.name, func() {
It("should return the expected results for "+c.name, func() {
/// checking
})
})
Or an anonymous function can have the same effect:
for _, c := range cases {
func (c struct{name string}) {
Context(c.name, func () {
It("should return the expected results for "+c.name, func () {
/// checking
})
})
}(c)
}
@onsi Can you help me? look this issue