【问题标题】:How to install Cobertura in azure Devops?如何在 azure Devops 中安装 Cobertura?
【发布时间】:2019-12-10 19:09:51
【问题描述】:

我在 Azure devops 中有一个带有 CI 的 .net 核心。

在成功运行我的单元测试后,我想根据这篇文章使用 ReportGenerator 生成和显示代码覆盖率:

https://www.meziantou.net/computing-code-coverage-for-a-dotnet-core-project-with-azure-devops-and-coverlet.htm

YAML 的一部分:

- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:$(Build.SourcesDirectory)/**Tests/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:HtmlInline_AzurePipelines;Cobertura
 displayName: Create Code coverage report

这给了我以下错误:

...line 2: Cobertura: command not found

通过从报告类型中删除 Cobertura,没有错误,但是没有要显示的报告。

如何安装或启用 Cobertura?

【问题讨论】:

    标签: unit-testing docker code-coverage azure-pipelines cobertura


    【解决方案1】:

    这样你就跳过了一个参数选项。根据文档,您可以尝试使用" 包装该选项,如下所示:

        - script: |
    dotnet tool install -g dotnet-reportgenerator-globaltool
    reportgenerator -reports:$(Build.SourcesDirectory)/**Tests/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage "-reporttypes:HtmlInline_AzurePipelines;Cobertura"
     displayName: Create Code coverage report
    

    如果不跳过它,这应该也可以工作。

    【讨论】:

      【解决方案2】:

      通过从报告类型中删除 HtmlInline_AzurePipelines,它起作用了

      【讨论】:

        猜你喜欢
        • 2020-10-15
        • 2019-03-02
        • 1970-01-01
        • 1970-01-01
        • 2021-12-17
        • 2021-01-07
        • 2020-01-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多