Tuesday, January 2, 2018

Dotnet test–Set test output

In a previous post I mentioned how to run and publish your Visual Studio Unit tests on your build server. By using the dotnet test command with the –logger:trx option, tests results were generated in a format that can be published to TFS.

One problem we noticed when applying this solution was that the default naming convention sets a unique name(based on the test execution date) for every generated trx file. This sounds fine but the problem was that for every run of our build pipeline, new trx files were generated.

As a consequence, when trying to import the test results using the Publish Test Results task, test result files from previous builds were imported as well, resulting in an ever increasing number of published test results.

To solve this, I added an extra option to the dotnet test command and explicitly specify the filename:

dotnet test --logger trx;logfilename=TEST.trx
In the Publish Test Results task, I updated the wildcard to only include TEST.trx files:
**/TEST.trx 

No comments: