Shadow
Shadow

Reputation: 2478

How to log dotnet test output in junit format

dotnet test uses trx output by default. I am using trx2junit to convert it to junit, but this complicates CI setup.

Is it possible to output test report in junit format directly from dotnet test?

Upvotes: 8

Views: 10275

Answers (3)

Jakob Ojvind Nielsen
Jakob Ojvind Nielsen

Reputation: 972

  1. change directory into the same directory as your .csproj file
  2. install the JUnitXmlLogger by executing dotnet add package JUnitXml.TestLogger
  3. execute your test with dotnet test --logger:junit

This will create the test result file in

<csproj-dir>\TestResults\TestResults.xml

To name the result file different, execute the test with i.e.

dotnet test --logger:"junit;LogFileName=my-test-results.xml"

Upvotes: 1

Thierry Br&#233;mard
Thierry Br&#233;mard

Reputation: 899

anyone knows how to install junit logger (if it is possible ?) on system that can be enumerated via this command ?

  • vstest.console /ListLoggers

I find the need to install package on csproj quite crappy

Upvotes: 0

Muhammad Rehan Saeed
Muhammad Rehan Saeed

Reputation: 38497

  1. Install the NuGet package to your test project:

    <PackageReference Include="JunitXml.TestLogger" Version="3.0.110" />
    
  2. Run the following command to output the test results in JUnit XML format:

    dotnet test --logger:junit
    

More info here:

Upvotes: 15

Related Questions