Is your feature request related to a problem? Please describe.
In Kubernetes, we encourage writing tests so that each It callback gets a context from Ginkgo and then passed that context on to gomega.Eventually/Consistently. This is easy to get wrong, so we have instructions: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/writing-good-e2e-tests.md#interrupting-tests
I am not sure how many of those gotchas can be detected through static analysis.
Not mentioned there (but probably should be):
It(func(ctx context.Context) {
// Should pass ctx!
Eventually(func() {
// Should not use ctx from It, but rather from func(ctx context.Context) { ... }
... Get(ctx, ...)
}).Should(...)
})
Describe the solution you'd like
- Optional: require that Ginkgo callbacks take a context if the callback needs a context (i.e. has a context.TODO or context.Background or calls gomega.Eventually/Consistently)
- Optional: require that
gomega.Eventually/Consistently are called with a context (whether it is as first parameter or through WithContext (I think there is such a thing...)
- Always: if gomega.Eventually/Consistently is called with a context, then it's callback should also accept a context if it needs one.
Is your feature request related to a problem? Please describe.
In Kubernetes, we encourage writing tests so that each
Itcallback gets a context from Ginkgo and then passed that context on togomega.Eventually/Consistently. This is easy to get wrong, so we have instructions: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/writing-good-e2e-tests.md#interrupting-testsI am not sure how many of those gotchas can be detected through static analysis.
Not mentioned there (but probably should be):
Describe the solution you'd like
gomega.Eventually/Consistentlyare called with a context (whether it is as first parameter or throughWithContext(I think there is such a thing...)