使用 Visual Studio Runner 为 xUnit 生成 XML 报告

nyn*_*n3x 5 xunit azure-pipelines visual-studio-2017

我只是使用 xUnit 测试设置了一个新项目 (.net 4.6.2)。为了在 VSTS 中进行单元测试,我在项目中添加了视觉工作室运行器(使用 nuget)。

现在我想知道:如何获得我的测试运行的 XML 报告,以便我可以在 VSTS 中发布这些结果?

Meg*_*gha 5

Xunit logger 可以生成 xunit v2 格式的 xml 报告(https://xunit.github.io/docs/format-xml-v2.html)。

  1. 在测试项目中添加对Xunit Logger nuget 包的引用
  2. 在测试中使用以下命令行 dotnet test --test-adapter-path:。--logger:xunit
  3. 测试结果在TestResults目录下生成,相对于test.csproj 报告文件的路径可以指定如下:dotnet test --test-adapter-path:。--logger:xunit;LogFilePath=loggerFile.xml loggerFile.xml 将在与 test.csproj 相同的目录中生成。


sta*_*SFT 1

您可以使用Visual Studio Test任务来运行XUnit,它可以将测试结果发布到VSTS。

对于Core xUnit测试,您可以通过在.Net Core Test任务中指定--configuration $(BuildConfiguration) --logger "trx"参数来生成trx测试结果,并添加Publish Test Results任务来发布测试结果(在测试结果格式中选择)VSTest