xUnit dotnet test CLi to output to NUnit xml so that Bamboo can read the results
Asked Answered
B

4

10

We are starting a new .net core project and we are just setting up Bamboo to build our project and run the tests and so my question is:

Is there a way that we can use the xunit dotnet test CLi test runner to output in NUnit format?

Currently we have: "dotnet test -xml TestResults.xml" to run our tests which works great except we can't get the results in Bamboo.

Or does anyone have an alternative that would work for us?

Biennial answered 17/9, 2016 at 3:19 Comment(2)
It is more of your self duty to see whether you can get Bamboo to support xUnit.net directly, or find a way to extend it, or to convert xUnit.net output to NUnit format.Jesus
Bamboo doesn't support xUnit directly and in .net 4.x using MSBuild you could get xUnit to ouput to NUnit format which bamboo can read. And i can't see that the new dotnet test CLi has this capability anymore / yet unless i have missed it which is possible as all the options don't seem to have been published as yet (i.e. -xml)Biennial
B
7

For those interested, .NET Core SDK 2.0 not longer supports the -xml option, but it does support --logger which can be used to select specific output formats including MSTest (.trx), which is supported by Bamboo.

Example invocation:

dotnet test --logger "trx;LogFileName=abc.trx"

Note: abc.trx can be a relative or absolute path, including ellipsis.

Blackguard answered 2/11, 2017 at 10:33 Comment(0)
A
2

I have created a plugin for parsing xunit results in bamboo and published on the atlassian marketplace.

It should support v1, v2 and dotnet test outputs for xunit.

https://marketplace.atlassian.com/plugins/com.wwwlicious.xunit.xunit/server/overview

hope this helps.

Algonquin answered 2/2, 2017 at 14:34 Comment(0)
B
1

For anyone who comes along this and is interested. I posted the issue on xUnit's github here: https://github.com/xunit/xunit/issues/977 and was refered to another issue that is to be release here: https://github.com/dotnet/corefx/issues/5593

I haven't as yet confirmed that the NUint output format is indeed going to be released as yet but thought i would post it anyway.

Biennial answered 20/9, 2016 at 6:52 Comment(0)
I
0

Edit

Apologies, I missed your mention of .net core.

Although it's not documented, apparently you can pass -xml filename.xml to dotnet test, which will output xUnit v1 XML. Unfortunately dotnet-test-xunit doesn't suppport converting that output into NUnit-format, but xunit proper does maintain an XSL transform to do it.

Original Answer

Assuming you're using xunit.runner.console, you can simply run:

xunit.console.exe Assembly.dll  -nunit test-results.xml

And then use Bamboo's NUnit parser to process the results.

Imparisyllabic answered 17/9, 2016 at 6:11 Comment(3)
Unfortunately only if it was that simple. With .net core I can't seem to run that command on the build server as xunit.console.exe does not exist even though i have the nuget package installed in my application. It appears that all nuget packages in .net core are hidden somewhere and so there is no assemblies to be found not even in the bin folder.Biennial
Thanks but again as per my original post we are already using the -xml option but it outputs in xUnit format and no NUnit format.Biennial
@Biennial Good point, apologies. Looks like there's nothing built in for the netcore runner, but there is an XSLT you can use to transform it yourself (see updated answer).Imparisyllabic

© 2022 - 2024 — McMap. All rights reserved.