gpt4 book ai didi

unit-testing - 在 azuredevops 管道中发布代码覆盖率结果失败

转载 作者:行者123 更新时间:2023-12-03 23:49:08 26 4
gpt4 key购买 nike

我的管道中有一个 .netcode 测试命令和一个发布代码覆盖率结果任务。

配置如下:

steps:
- task: DotNetCoreCLI@2
displayName: 'Test Public API Project '
inputs:
command: test
projects: '**/DWP.CDA.API.Test.csproj'
arguments: '--output publish_output --configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Threshold=99 /p:ThresholdStat=total /p:CoverletOutput=$(Build.SourcesDirectory)\TestResults\Coverage\ --collect "Code coverage"'

steps:
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/TestResults/Coverage/*cobertura.xml'
reportDirectory: '($(Build.SourcesDirectory)/Src/TestResults/Coverage'

但是好像发布结果没有生效,会显示这样的消息
[warning]No code coverage results were found to publish.

最佳答案

您是否也安装并运行了 ReportGenerator 工具以获取正确格式的代码覆盖率报告?您的警告看起来像是构建任务没有在您正在查看的文件夹中找到要发布的 xml 文件。

我过去使用过以下 yaml 来运行和发布代码覆盖率结果。您需要更改它才能找到您的项目,否则它应该可以工作。

- task: DotNetCoreCLI@2
displayName: 'Install ReportGenerator'
inputs:
command: custom
custom: tool
arguments: 'install --global dotnet-reportgenerator-globaltool'

- task: DotNetCoreCLI@2
displayName: 'Run unit tests - $(buildConfiguration)'
inputs:
command: 'test'
arguments: '--no-build --configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/'
publishTestResults: true
projects: '**/*.Tests.csproj'

- script: |
reportgenerator -reports:$(Build.SourcesDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:HtmlInline_AzurePipelines
displayName: 'Create code coverage report'

- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage report'
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(Build.SourcesDirectory)/**/coverage.cobertura.xml'

关于unit-testing - 在 azuredevops 管道中发布代码覆盖率结果失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60275777/

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