【问题标题】:Producing a xUnit test output similar to Junit output on gitlab CI在 gitlab CI 上生成类似于 Junit 输出的 xUnit 测试输出
【发布时间】:2022-02-23 17:06:31
【问题描述】:

我们有.NET Core 3 代码库,单元和集成测试在Gitlab CI 上运行。 问题是,当一个或多个单位/整数。测试失败,没有显示任何具体内容,您必须查看整个管道转储并搜索以查看单个失败的测试。

https://docs.gitlab.com/ee/ci/unit_test_reports.html,Junit 报告正好解决了这个问题。

咨询How to capture structured xUnit test output in Gitlab 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   

行?

【问题讨论】:

    标签: junit gitlab continuous-integration gitlab-ci xunit


    【解决方案1】:

    您不必合并报告。 artifacts:reports:junit 键接受多个值,包括全局模式。

      artifacts:
        reports:
          junit:
            - "test.xml"
            - "./tests/*.xml"
    

    因此,一种解决方案是将所有 XML 输出文件放在特定目录中,并在 .gitlab-ci.yml 文件中使用与许多文件匹配的 glob 模式。

    如果您真的想合并 xUnit XML 文件,请参阅 this answer

    【讨论】:

      猜你喜欢
      • 2019-12-25
      • 2017-05-04
      • 2011-02-12
      • 1970-01-01
      • 2018-08-18
      • 2016-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多