You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a proposal to add a Name() string function to testing.TB that returns the name of the test/benchmark. This is necessary to differentiate between debugging messages, events, traces etc when running tests/benchmarks in parallel.
In many cases one can figure out the enclosing Test.. function by studying the caller stack but that wouldn't work for subtests. This feature would be especially useful when the subtests are generated programatically, e.g. for i := 1; i <= 5; i++ { t.Run(fmt.Sprintf("i=%d", i), ..)
The text was updated successfully, but these errors were encountered:
I feel like this is solving the wrong problem; the TB already knows which subtest it is for, maybe the log output should just be changed to prepend every log message with the name of the test?
Also the hypothetical JSON output (#2981) separates log messages by test.
That is only helpful for logs that go through TB. Tests might spin up non-testing machinery which can have its own internal methods for outputting debug messages. Plus this is not limited to printed logs, it could be used for other things like traces (e.g. LightStep).
This is a proposal to add a
Name() string
function totesting.TB
that returns the name of the test/benchmark. This is necessary to differentiate between debugging messages, events, traces etc when running tests/benchmarks in parallel.In many cases one can figure out the enclosing
Test..
function by studying the caller stack but that wouldn't work for subtests. This feature would be especially useful when the subtests are generated programatically, e.g.for i := 1; i <= 5; i++ { t.Run(fmt.Sprintf("i=%d", i), ..)
The text was updated successfully, but these errors were encountered: