Brian Ball
Brian Ball

Reputation: 12596

Unable to publish nunit test results to Visual Studio Team Services

I'm setting up Continuous integration in Team Services. The solution currently has a couple of unit test projects. All projects in the solution are .NET core projects.

The out of the box test runner in the build definition isn't pick up any of the unit tests projects (yes, the test assembly wildcards are setup correctly), so I've resorted to writing a batch file that executes dotnet test. After the command runs, an XML file is written to the disk which contains the results. I'm using the publish results step and pointing to that file so that the test results will show up in the build output. I've set the "Test Result Format" field to NUnit, but that step produces the following warning:

Invalid results file. Please make sure the Test Result Format field in the task matches the result format of the file: C:\<path to file>\TestResult.xml

Has anyone else been able to publish NUnit test results that were generated from running the dotnet test command in Team Services?

Upvotes: 0

Views: 2588

Answers (3)

Velimir
Velimir

Reputation: 752

I was able to publish my test results by using dotnet test task in combination with Publish Test Results. The build configuration looks like this:

  1. In the dotnet test task, add additional argument --logger:trx enter image description here
  2. Add a Publish Test Result task after the test task, and configure it with:

Test result format: VSTest

and

Test results files: ***.trx

enter image description here

Upvotes: 0

Eddie Chen - MSFT
Eddie Chen - MSFT

Reputation: 29958

This is because VSTS does not support NUnit3 format. You can consider to use the workarounds mentioned by jirisykora83 and CharliePoole in this question: Support NUnit2 format.

Upvotes: 1

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51073

Seems you have to run your own batch script to run tests. Even though you have set in the batch script that dotnet test should generate NUnit file, but in publish task it may not be NUnit option. You can give a try with JUnit Format or XUnit Format in the Test Result Format.

enter image description here

Upvotes: 0

Related Questions