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 (1) -

  • 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.

Add comment

Loading