看不到 .Net Core bitbucket 管道测试结果

Can't see .Net Core bitbucket pipelines test results

我终于通过这个命令在 bitbucket 管道中生成了我的测试报告:

- dotnet test MyTests --logger "trx;LogFileName=test-reports/results.xml"

构建拆解说:

Found matching test report file MyPath/test-reports/results.xml
Finished scanning for test reports. Found 1 test report files.
Merged test suites, total number tests is 0, with 0 failures and 0 errors.

但是,我在bitbucket中看不到这些测试结果文件。我知道管道 window 中应该有一个新选项卡或类似的东西。有什么建议可以很好地显示它们 window?

未找到任何文档或文章。

Bitbucket 管道仅接受 JUnit xml 格式。您需要添加 JUnitTestLogger 并将命令更改为 dotnet test "--logger:junit;LogFilePath=./test-reports/results.xml"

我找到了 3 种方法-

  1. 添加 JUnitTestLogger 工具并将输出设置为 JUnit .

  2. 将输出设置为 TRX(默认包含在 dotnet test 中)。然后用trx2junit转成JUnit格式

  3. 添加 XUnit 工具并将输出设置为 XUnit。然后用xunit-to-junit转成JUnit格式

您采用的方法可能取决于最容易安装的工具。

另请注意,Pipelines 在“build teardown”中告诉我们它正在“在名为 [test-results, failsafe-reports, test-reports, surefire-reports] 的目录中搜索测试报告文件到一个深度4 英寸。默认情况下,dotnet test 将结果放在名为“testresults”的文件夹中,因此需要使用 -r(也称为 --reports-directory)选项指定有效目录。