生成类似于 gitlab CI 上的 Junit 输出的 xUnit 测试输出
我们有 .NET Core 3 代码库,单元测试和集成测试在 Gitlab CI 上运行。 问题是,当一个或多个单位/整数。测试失败,没有显示任何具体内容,您必须查看整个管道转储并搜索以查看单个失败的测试。
查看 https://docs.gitlab.com/ee/ci/unit_test_reports.html< /a>,Junit报告正是解决这个问题。
咨询 如何在 Gitlab 中捕获结构化 xUnit 测试输出CI?,我仍然找不到合适的解决方案。 主要问题是,有多个使用 dotnet test 命令执行的测试项目:
gitlab.yaml 文件的当前快照:
artifacts:
when: always
reports:
junit: ./Test.xml
script:
- for proj in $(dotnet sln MySolution.sln list | grep 'Test.csproj$'); do dotnet test --logger "junit;LogFilePath=Test.xml" $proj; done
现在有问题的是脚本部分,我们在其中迭代所有测试程序集并对每个项目进行 dotnet 测试。
有没有办法以某种方式从每个项目中生成一个 junit xml 日志文件并将其提供给行中的 junit 测试报告
reports:
junit: ./Test.xml
?
We have .NET Core 3
codebase and the unit and integration tests are ran on the Gitlab CI
.
Problem is, when one or more unit/int. tests fail, nothing specific is shown, you have to look at the entire pipeline dump and search to see for individual failed tests.
Looking at https://docs.gitlab.com/ee/ci/unit_test_reports.html, Junit report is exactly solving this issue.
Consulting with the How to capture structured xUnit test output in Gitlab CI?, I still wasn't able to find a proper solution.
Main problem is, there are multiple test projects that are executed with the dotnet test
command:
current snapshot of gitlab.yaml file:
artifacts:
when: always
reports:
junit: ./Test.xml
script:
- for proj in $(dotnet sln MySolution.sln list | grep 'Test.csproj
Now the problematic is the script part, where we iterate through all the test assemblies and do the dotnet test for each project.
Is there a way to somehow produce a single junit xml log file out of each project and feed it to junit test report in the
reports:
junit: ./Test.xml
line?
); do dotnet test --logger "junit;LogFilePath=Test.xml" $proj; done
Now the problematic is the script part, where we iterate through all the test assemblies and do the dotnet test for each project.
Is there a way to somehow produce a single junit xml log file out of each project and feed it to junit test report in the
line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不必合并报告。
artifacts:reports:junit
键接受多个值,包括 glob 模式。因此,一种解决方案是将所有 XML 输出文件放在特定目录中,并在 .gitlab-ci.yml 文件中使用与许多文件匹配的 glob 模式。
如果您确实想合并 xUnit XML 文件,请参阅此答案
You don't have to combine the reports. The
artifacts:reports:junit
key accepts multiple values, including glob patterns.So, one solution would be to have all your XML output files in a particular directory and use a glob pattern in your
.gitlab-ci.yml
file that matches the many files.If you really want to merge the xUnit XML files isntead, see this answer