gotest: add -xunit for xunit output (nicer integration with CI systems).

608 views
Skip to first unread message

Miki Tebeka

unread,
Sep 29, 2011, 1:26:20 PM9/29/11
to golan...@googlegroups.com, golan...@googlegroups.com
I'll like to add -xunit parameter to gotest which will output XML formatted output in XUnit format. This will make integration with CI tools (such as Jenkins) easier.
The value of -xunit will be the name of the output file, this won't change the regular output of gotest.

Any thoughts?

Jan Mercl

unread,
Sep 29, 2011, 1:35:58 PM9/29/11
to golan...@googlegroups.com, golan...@googlegroups.com
On Thursday, September 29, 2011 7:26:20 PM UTC+2, Miki Tebeka wrote:
Any thoughts?

gotest 2>&1 | myGotest2xml > file.xml

Dmitry Vyukov

unread,
Sep 29, 2011, 1:36:15 PM9/29/11
to golan...@googlegroups.com, golan...@googlegroups.com
You may create a simple separate format converter.

Miki Tebeka

unread,
Sep 29, 2011, 2:22:30 PM9/29/11
to golan...@googlegroups.com, golan...@googlegroups.com

You may create a simple separate format converter.
Yeah, but instead of everyone doing the thing over and over again, I thought it'll be nice to have it in one place.

Dmitry Vyukov

unread,
Sep 29, 2011, 2:25:40 PM9/29/11
to golan...@googlegroups.com, golan...@googlegroups.com
On Thu, Sep 29, 2011 at 10:22 PM, Miki Tebeka <miki....@gmail.com> wrote:

You may create a simple separate format converter.
Yeah, but instead of everyone doing the thing over and over again, I thought it'll be nice to have it in one place.

What is preventing people from having the conversion script in one place?

Miki Tebeka

unread,
Sep 29, 2011, 2:54:07 PM9/29/11
to golan...@googlegroups.com, golan...@googlegroups.com

What is preventing people from having the conversion script in one place?
Nothing. However if you go that route why have gotest utility as well? People can write their own.
You place things in the standard library if you think it'll benefit most of the people, I think this feature fits this description.

Dmitry Vyukov

unread,
Sep 29, 2011, 3:04:26 PM9/29/11
to golan...@googlegroups.com, golan...@googlegroups.com
I for one use gotest but do not know what is XUnit.

John Asmuth

unread,
Sep 29, 2011, 4:06:56 PM9/29/11
to golan...@googlegroups.com, golan...@googlegroups.com
On Thursday, September 29, 2011 3:04:26 PM UTC-4, Dmitry Vyukov wrote:
I for one use gotest but do not know what is XUnit.

Seconded. 

hun...@cloudflare.com

unread,
May 8, 2016, 12:32:44 AM5/8/16
to golang-nuts, golan...@googlegroups.com
Followup: to the OP's great credit, he's maintained the converter ever since.

Thousands of engineers use xunit -- it's what Jenkins and most any non-Google CI parse to generate test reports. Not really sure that ignorance (seconded!) was a valid argument here, but maybe it just gives wise to the old family saying that Ignorance is Contagious. :-) Understandable to keep it out of stdlib, though.

The example above for executing a converter isn't quite what one wants -- raw test output still needs to go to stdout for the CI to have it in the logs (also: pipefail). The OP's repo suggests a better way:

go test -v | tee $outfile
go2xunit -fail -input $outfile -output tests.xml
 
Reply all
Reply to author
Forward
0 new messages