我在管道中有一个.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.
答案 0 :(得分:3)
您是否还安装并运行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'
答案 1 :(得分:0)
我遇到了类似的问题,看看输出
Attachments:
我的管道将报告放入临时文件夹
我的测试项目也缺少 Nuget coverlet.msbuild