Vstest: Add support for `dotnet test` to have JUnit style output

Created on 4 Feb 2019  路  10Comments  路  Source: microsoft/vstest

_From @wordshaker on February 4, 2019 12:6_

The Problem

Using CircleCI as a build tool, there are some features you can only get access to if your test output is in a JUnit format. XUnit provides a -junit argument to transform XUnit output to a JUnit style of output and it seems similar functionality used to be supported: https://stackoverflow.com/questions/39542533/xunit-dotnet-test-cli-to-output-to-nunit-xml-so-that-bamboo-can-read-the-results/47073101

I've tried using the --logger option in a few ways, but can't find a way of achieving what I want without using another package.

Is it possible to use the XUnit Transforms out the box with dotnet test?

Expected behavior

  • To be able to run an argument as part of dotnet test that enables the test output to be transformed into an expected format.

Actual behavior

  • Can use the --logger argument to output to xml or trx, but the tool I'm using explicitly needs a trx with JUnit formatting

_Copied from original issue: dotnet/cli#10698_

enhancement

Most helpful comment

@danjcosg to output in JUnit format you can add a reference to the JUnit Logger nuget package in your test project and then use the following command to run tests
dotnet test --test-adapter-path:. --logger:junit

See more usage details: https://github.com/spekt/junit.testlogger#usage

All 10 comments

@livarcocc, I'm not sure by what you mean by trx with JUnit formatting

If you're looking for a --logger:JUnit option, then this is explicitly an enhancement ask. There are OSS repos available for this, a quick lookup found me this https://github.com/alexkosau/vstest-junit-logger

I just moved the bug here since it was filled on the CLI and I don't believe it belongs there. The original person who filled the bug is @wordshaker. And yes, I believe this would be a feature request.

Thanks for moving it @livarcocc - I wasn't really sure where it should live.

@karanjitsingh - I know there are OSS repositories available for this, but as we are already using XUnit it would be nice to be able to use their implementation. A nice to have rather than a dire need.

@karanjitsingh Can appreciate that the vstest team want to keep loggers decoupled, I think the request is that dotnet test and XUnit are more functionally equivalent? So would that make it a CLI feature to add a JUnit logger option within dotnet test?

It's been a while since we've had activity on this issue. I'm wondering if the ask is mostly satisfied by 3rd party nuget packages such as https://www.nuget.org/packages/JUnitTestLogger. That seems to be the most popular solution.

Is there still a strong ask that we add the junit output format to the built-in tools?

Thank you for the feedback.

My team would find it really useful @kendrahavens. For Jenkins CI, the solutions we're using at the minute either involve the MSBuild plugin or 3rd party XSLT file. Outputting TRX directly would simplify things nicely

@danjcosg To clarify, would you like to output a trx in junit format? (dotnet test --logger trx can already output a trx directly.)

@kendrahavens sorry, typo, I meant ability to output in JUnit format would be useful!

Gotcha, thanks!

@danjcosg to output in JUnit format you can add a reference to the JUnit Logger nuget package in your test project and then use the following command to run tests
dotnet test --test-adapter-path:. --logger:junit

See more usage details: https://github.com/spekt/junit.testlogger#usage

Was this page helpful?
0 / 5 - 0 ratings