How do I get .NET Core 2.0 xUnit test reports produced and published into VSTS?
Follow the getting started as per this document:
https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-dotnet-test
Importantly, this must be in your test project file:
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
Now in your VSTS build configuration you need to pretend like it's all VSTest and not choose or try to use the xUnit runner and reporting formats.
So, add a .NET Core task as v2.0 (preview) and set, in additional to other obvious settings:
Command: test
Arguments: --logger:trx --configuration $(BuildConfiguration)
Now add a good old fashioned Publish Test Results task and set:
Test result format: VSTest
Test results files: **\*.trx
Merge test results: check
Upload test results files: check
I think now the Visual Studio runner will run as xUnit, but produce its own reporting format that VSTS copes with.
Note The only bug I saw was that the 'Run duration' was crazy long in the report.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With