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.

image

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

image

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

image

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

image

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:

--logger:trx

image

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.

image

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.

image

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

image

Comments (8) -

  • Chris Patterson

    5/12/2017 1:27:52 PM | Reply

    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.

  • Alfred

    9/21/2017 11:32:44 PM | Reply

    And what about code coverage?

    • Donovan

      10/2/2017 2:53:15 PM | Reply

      There is no cross-platform code coverage tool for .net core.

  • Tarig0

    12/13/2017 5:14:34 PM | Reply

    You can now use the XunitXML.TestLogger nuget package to do this.

    --configuration $(BuildConfiguration) -l:xunit -rEmbarassed(Common.TestResultsDirectory)

  • Tarig0

    12/13/2017 5:17:11 PM | Reply

    Also To get failed tests to publish you have to continue on error in the dotnet test step

  • Matt

    8/13/2018 12:36:42 PM | Reply

    Thanks for this.

Add comment

Loading