Processing test json data

97 views
Skip to first unread message

vedu...@gmail.com

unread,
May 19, 2018, 10:25:24 AM5/19/18
to golang-nuts
I see that in go1.10, we can have json formatted "go test" output (by using -json flag)
I googled around, but couldn't find a simple way/tool to convert it to junitxml format

Any suggestions?

Karan Chaudhary

unread,
May 22, 2018, 5:59:40 AM5/22/18
to golang-nuts
Will this help? https://github.com/aaronbriel/jsonjunit

I haven't tried it but piping the json output to jsonjunit can help.

vjo...@ves.io

unread,
Jun 1, 2018, 9:45:20 AM6/1/18
to golang-nuts
Thanks, I hadnt tried this as this seemed to be meant for mocha testing framework. Let me check

Manlio Perillo

unread,
Jun 1, 2018, 10:26:04 AM6/1/18
to golang-nuts
The JSON output used by go test -json is defined in:

Converting to junitxml should be trivial.
Each entry, excluding the last, can be mapped to a testcase xml element, and the last entry to a testsuite xml element (since it reports the total elapsed time).
If more than one package is tested, things are e bit more complex.

One unfortunate thing is that the TestEvent type does not have a name/description/label/comment field to record the optional comment of the test function.
The name/description/label/comment can be mapped to the name attribute of the testcase xml element.


Manlio
Reply all
Reply to author
Forward
0 new messages