Where are My Test Results?

Today I decided to start upgrading yo team to the .csproj project format for .NET Core.  Once I had a sample project it was time to create the build definition.  Visual Studio Team Services has a template to build .NET Core so I decided to start with that.


The template looked promising because it had add the required steps including running my unit tests.


However, after my build was done I did not have any test results.


After reviewing my build log I could see tests were executed.


After doing some research I realized I had to instruct the test task to write out a log file and add a task to publish the results.  To have a log file generated during the test run add following argument to the test task:



With that argument in place a .trx file will be created.  Now all we have to do is publish it with the Publish Test Results task.


Use the following values to configure the task.

Field Name Value
Version 2.* (preview)
Display name Publish Test Results
Test result format VSTest
Test results files **/*.trx
Search folder $(System.DefaultWorkingDirectory)
Merge test results [check]
Test run title Unit
Platform $(BuildPlatform)
Configuration $(BuildConfiguration)
Upload test results files [check]

Your final build should look like the image.


Now queue a new build and you should have test results.


Comments (7) -

  • I would also add

    -- RunConfiguration.ResultsDirectory=$(Common.TestResultsDirectory)  That space after the -- is intentional so leave it.

    to the arguments for dotnet test. Then publish from the $(Common.TestResultsDirectory).  That way if you have a private agent and are not doing clean builds you won't double publish your test results.
  • And what about code coverage?
    • There is no cross-platform code coverage tool for .net core.
  • You can now use the XunitXML.TestLogger nuget package to do this.

    --configuration $(BuildConfiguration) -l:xunit -rEmbarassed(Common.TestResultsDirectory)
  • Also To get failed tests to publish you have to continue on error in the dotnet test step

Add comment