Testing .NET Core projects as part of a build in Team Foundation Server is relatively easy – just add a Test .NET Core task – but collecting and publishing the results so that they can be viewed in the UI is a bit trickier. Since I’m using XUnit as testing framework, I tried using their dotnet xunit command, but it didn’t work. After some searching and experimenting, I came up with the following solution.
- Add the following arguments to the Test .NET Core task:
–no-restore –no-build –configuration $(BuildConfiguration) –logger trx
The important part here is the logger parameter.
- Add a Publish Test Results task with the following options:
Test Result Format: VSTest
Test Result Files: **/*.trx