Feature request: Report subtests results before the top level test ends
I'd love to get details of the subtests with the testname reporter before all of them are executed.
Currently, I only get the result when all the subtests are executed.
Thank you for the feature request!
I think unfortunately this will be difficult to implement because go test doesn't send the subtest pass/fail events immediately. You can see the implementation for the testname formatter here: https://github.com/gotestyourself/gotestsum/blob/main/testjson/format.go#L44-L87
That function is called for every event received from go test. There's no buffering of events or anything like that. I haven't tested it, but I think that means it is actually go test that is holding the events until the parent test completes.
I think go test would need to send these events earlier for this to work.
I'm curious, are you using t.Parallel with the subtests? I wonder if that changes the behaviour.
https://go-review.googlesource.com/c/go/+/443596 (which I think will be released in go1.20) mentions that it fixes this problem. So there's a good chance this problem will be fixed in the next Go release.
go1.20 is out now
From: https://go.dev/doc/go1.20#go-command
The implementation of go test -json has been improved to make it more robust. Programs that run go test -json do not need any updates. Programs that invoke go tool test2json directly should now run the test binary with -v=test2json (for example, go test -v=test2json or ./pkg.test -test.v=test2json) instead of plain -v.
I stumbled upon this github issue and I can confirm that updating to go 1.20 shows the subtest results immediately
Thank you for confirming! I'm going to close this issue since it appears to be resolved by changes in the go toolchain.