.net-core - 如何将 .NET Core 2.0 xUnit 测试报告导入 VSTS

标签 .net-core azure-devops xunit dotnet-cli

如何生成 .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/

相关文章:

c# - 在 ASP.NET Core 中使用 ConfigureAppConfiguration 方法进行日志记录

asp.net-mvc - 当 Copy-Local 设置为 True 时,为什么 Azure 部署中缺少 DLL?

f# - 使用 FsUnit.Xunit 断言异常消息

c# - Entity Framework Core 3.0 中的自有类型问题

.net core 控制台应用程序中的 c# Main() 函数

json - 解析 terraform plan 输出以检查模块与资源 block 的使用情况

azure - 通过DevOps API创建端点创建服务端点时设置 "Allow all pipelines"

unit-testing - linux 主机中 .net core 的代码覆盖率

macos - 在 OSX 上运行 xunit.console.runner

c# - ASP.Net Core Web API 捕获用于日志记录的 HTTP 请求