Closed
Description
Proposal: add a test-local Context
object to testing.T
objects. The object would be accessible like this:
func TestSomething(t *testing.T) {
ctx = t.Context()
...
}
It would be cancelled at the end of the test. This would allow tests involving network calls, parallel goroutines, or other blocking code to use the context to cancel all the background stuff in the event the test fails an assertion early with FailNow
or something similar.
It should be a fairly straightforward feature, so if there's interest I can create a Pull Request when I have time.