如何生成 .NET Core 2.0 xUnit 测试报告并将其发布到 VSTS 中?
最佳答案
按照本文档的入门指南进行操作:
https://docs.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-dotnet-test
重要的是,这必须在您的测试项目文件中:
<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>
现在,在您的 VSTS 构建配置中,您需要假装它都是 VSTest,而不是选择或尝试使用 xUnit 运行程序和报告格式。
因此,除了其他明显的设置之外,添加一个 .NET Core 任务作为 v2.0(预览版)并设置:
Command: test
Arguments: --logger:trx --configuration $(BuildConfiguration)
现在添加一个很好的老式发布测试结果任务并设置:
Test result format: VSTest
Test results files: **\*.trx
Merge test results: check
Upload test results files: check
我认为现在 Visual Studio runner 将作为 xUnit 运行,但会生成 VSTS 处理的自己的报告格式。
Note The only bug I saw was that the 'Run duration' was crazy long in the report.
关于.net-core - 如何将 .NET Core 2.0 xUnit 测试报告导入 VSTS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46589521/