-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: add context.Context
objects to testing.T
EDIT: and testing.M
#18182
Comments
I think this has already been done, no?
https://tip.golang.org/pkg/testing/#T.Context
|
Right you are! I wasn't looking at |
@Lucretiel, what was your motivation for wanting this, out of curiosity? |
I have an internal Originally, my request was to add the feature to gocheck (go-check/check#88). In particular, I thought it'd be nice to have a single, suite-level Actually, since I just discovered that |
context.Context
objects to testing.T
context.Context
objects to testing.T
EDIT: and testing.M
Sounds good. Ty for the update. |
Proposal: add a test-local
Context
object totesting.T
objects. The object would be accessible like this: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.
The text was updated successfully, but these errors were encountered: