testing: document rules for using TB #41269
Open
Milestone
Comments
Related to #40343, though that one claims that the docs allude to it; however, I can't find the quoted snippet. |
Personally, I think most of those rules should be relaxed. We could document that Fatalf just calls runtime.Goexit (and document that it won't actually abort the entire test). We could allow Logf to run after the test has ended (and document that the logged value won't appear if it has). Having extra rules on the testing infrastructure makes it harder to diagnose the real problems, in my view, and sometimes non-conformance is accidental (for example if a goroutine that's calling |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's rules about what a
TestFoo
may do with the*testing.T
it is given. Some are documented (e.g. https://golang.org/pkg/testing/#T puts restrictions on invokingFatalf
and friends), but some are not (e.g.Logf
and probably most other methods should not be called afterTestFoo
returns). Same applies to*testing.B
and any future such values/types.I came across this while trying to diagnose a problem that seems to be due to #40908, but realised I couldn't find the rules written down anywhere.
The text was updated successfully, but these errors were encountered: