Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate XML-Report for xUnit using Visual Studio Runner

I just setup a new project (.net 4.6.2) using xUnit Tests. In order to get unit-testing in VSTS I added the visual-studio runner to the project (using nuget).

Now I'm wondering: how do I get XML-Reports of my testruns, so I can publish those results in VSTS?

like image 714
nyn3x Avatar asked Oct 17 '17 11:10

nyn3x


2 Answers

Xunit logger can generate xml reports in the xunit v2 format (https://xunit.github.io/docs/format-xml-v2.html).

  1. Add a reference to the Xunit Logger nuget package in test project
  2. Use the following command line in tests dotnet test --test-adapter-path:. --logger:xunit
  3. Test results are generated in the TestResults directory relative to the test.csproj A path for the report file can be specified as follows: dotnet test --test-adapter-path:. --logger:xunit;LogFilePath=loggerFile.xml loggerFile.xml will be generated in the same directory as test.csproj.
like image 140
Megha Avatar answered Oct 02 '22 16:10

Megha


You can use Visual Studio Test task to run XUnit and it can publish the test result to VSTS.

Regarding Core xUnit test, you can generate the trx test result by specifying --configuration $(BuildConfiguration) --logger "trx" arguments in .Net Core Test task and add Publish Test Results task to publish test result (Choose VSTest in Test result format)

like image 27
starian chen-MSFT Avatar answered Oct 02 '22 15:10

starian chen-MSFT