/ go Public
cmd/test2json: output is incorrect and fails to mark tests if using
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
In summary, using the JSON output format seems to not function correctly when using
Assume two tests are available:
TestMain()is reserved and triggers
m.Run(). I noticed this when using a
go testto JUnit conversion tool. Initially, I thought that the bug was in the JUnit conversion tool, but then noted that the actions outputted by the
jsonflag (in other words
go tool test2json) had changed when I added
TestMain()passes, it does not get the
"Action": "run"field, and it is missing the
"Test":field in the JSON output. If it fails, it is registered as an individual test and has appropriate action fields.
TestSomethingElse()is called from TestMain, it is missing its
"Test":field in its JSON entirely on pass, but registers actions correctly if it fails.
With TestMain() calling it:
What version of Go are you using (
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
What did you do?
You can't actually run this in the code playground, as you need to run
go tool test2jsonon a compiled
go testbinary (or use the
Here's some test code you can paste into your environment, it's just TestMain() and a dummy test. https://go.dev/play/p/KDtlzPW9gDU
Compile it and run the binary as
go tool test2json -t ./your_binary.
The text was updated successfully, but these errors were encountered: