gpt4 book ai didi

azure - 代码覆盖率 - Azure Pipelines SonarQube

转载 作者:行者123 更新时间:2023-12-02 22:58:36 34 4
gpt4 key购买 nike

我使用 Azure 管道来运行单元测试和 SonarQube 集成。当我使用 cobertura 进行单元测试时,我无法将代码覆盖率结果传递到 SonarQube,尽管我在管道日志中看到结果。然而,当我使用 OpenCover 时,同样的事情也会发生。

我还在管道日志中看到此警告,尽管我不确定这是否相关:“缺少以下文件的责任信息”

管道目前如下所示

 - task: DotNetCoreCLI@2
inputs:
command: ‘test’
projects: |
<test-proj>
arguments: ‘/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura’
displayName: ‘Run Tests’

- task: SonarQubePrepare@4
inputs:
SonarQube: <Service-Endpoint>
scannerMode: ‘MSBuild’
projectKey: ‘test:service’
projectName: ‘test:service’
extraproperties: |
sonar.flex.cobertura.reportPaths=$(Build.SourcesDirectory)/**/coverage.cobertura.xml

- task: DotNetCoreCLI@2
<Running DotNet build>

- task: SonarAnalyze@4

运行 DotNet Test 阶段时,测试结果是通过以下路径获得的 -E:\agent-5\2\s\test\ApiTest\coverage.cobertura.xml

如有任何建议,我们将不胜感激。

最佳答案

更新:显然,SonarQube 默认情况下不允许发布 Cobertura 结果文件(或者至少我无法让它运行)。

使用了一种解决方法 - 我必须将 OpenCover 测试结果文件传递给 SonarQube。为了将结果推送到 Azure Devops,我必须使用 reportgenerator 工具将结果转换为 Cobertura,然后再将其传递到 Azure Devops。

关于azure - 代码覆盖率 - Azure Pipelines SonarQube,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66497001/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com