如何以 junit 格式记录 dotnet 测试输出

发布于 2025-01-17 04:42:57 字数 199 浏览 2 评论 0原文

dotnet test 默认使用 trx 输出。我正在使用 trx2junit 将其转换为 junit,但这会使 CI 设置变得复杂。

是否可以直接从 dotnet test 输出 junit 格式的测试报告?

dotnet test uses trx output by default. I am using trx2junit to convert it to junit, but this complicates CI setup.

Is it possible to output test report in junit format directly from dotnet test?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

街道布景 2025-01-24 04:42:57
  1. 将 NuGet 包安装到您的测试项目:

    >
    
  2. 运行以下命令以 JUnit XML 格式输出测试结果:

    dotnet 测试 --logger:junit
    

更多信息请参见:

  1. Install the NuGet package to your test project:

    <PackageReference Include="JunitXml.TestLogger" Version="3.0.110" />
    
  2. Run the following command to output the test results in JUnit XML format:

    dotnet test --logger:junit
    

More info here:

神回复 2025-01-24 04:42:57
  1. 将目录更改为与 .csproj 文件相同的目录
  2. 通过执行 dotnet add package JUnitXml.TestLogger 安装 JUnitXmlLogger
  3. 使用 dotnet test --logger:junit 执行测试

这将创建测试结果文件位于

\TestResults\TestResults.xml

执行测试

要将结果文件命名为不同的,请使用 ie dotnet test --logger:"junit;LogFileName=my-test-results.xml"

  1. change directory into the same directory as your .csproj file
  2. install the JUnitXmlLogger by executing dotnet add package JUnitXml.TestLogger
  3. execute your test with dotnet test --logger:junit

This will create the test result file in

<csproj-dir>\TestResults\TestResults.xml

To name the result file different, execute the test with i.e.

dotnet test --logger:"junit;LogFileName=my-test-results.xml"

追星践月 2025-01-24 04:42:57

有人知道如何在可以通过此命令枚举的系统上安装 junit 记录器(如果可能吗?)?

  • vstest.console /ListLoggers

我发现需要在 csproj 上安装软件包非常糟糕

anyone knows how to install junit logger (if it is possible ?) on system that can be enumerated via this command ?

  • vstest.console /ListLoggers

I find the need to install package on csproj quite crappy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文