问题描述
我遵循使用Azure DevOps和Coverlet为.NET Core项目计算代码覆盖率.
构建运行符合预期,并且每个步骤都成功结束.
Build run like expected and every step ends successfully.
Artefact-Explorer显示了上载的报告,总之,我得到了代码覆盖率结果.
The Artefact-Explorer shown the uploaded report and In summary I get the Code Coverage result.
但是我错过了 Tests 标签旁边的 Code Coverage 标签来查看详细的报告.
But I missing the Code Coverage tab next to Tests tab to take a look to the detailed report.
配置YAML:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 5.0.2'
inputs:
versionSpec: 5.0.2
checkLatest: true
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.solution)'
- task: VSBuild@1
displayName: 'Projektmappe **\*.sln erstellen'
inputs:
solution: '$(Parameters.solution)'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: VisualStudioTestPlatformInstaller@1
displayName: 'Installer für Visual Studio Test-Plattform'
enabled: false
- task: VSTest@2
displayName: 'VsTest - testAssemblies'
inputs:
testAssemblyVer2: |
**\$(BuildConfiguration)\*test*.dll
!**\obj\**
codeCoverageEnabled: true
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- powershell: ./'D:\AzureDevOpsData\Skripte\PowerShell\CodeCoverage.ps1'
displayName: 'PowerShell Test Code Coverage'
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
displayName: ReportGenerator
inputs:
reports: coverage.cobertura.xml
targetdir: '$(Build.SourcesDirectory)/CodeCoverage'
- task: PublishCodeCoverageResults@1
displayName: 'Code Coverage veröffentlichen von $(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage'
PowerShell脚本包含:
#TEST CSPROJ
$csproj = "FrameworkA_Tests"
#SEARCH TEST CSPROJ.DLL
"`nrun tests:"
$unitTestFile = gci -Recurse | ?{ $_.FullName -like "*bin\*$csproj.dll" }
Write-Host "`$unitTestFile value: $unitTestFile"
#GET COVERLET.EXE
$coverlet = "D:\AzureDevOpsData\Tools\coverlet\coverlet.exe"
#RUN COVERLET.EXE
"calling $coverlet for $($unitTestFile.FullName)"
&$coverlet $unitTestFile.FullName --target "dotnet" --targetargs "vstest $($unitTestFile.FullName) --logger:trx" --format "cobertura"
我忘记了什么吗?
推荐答案
这应该是开发者社区中的一个已知问题:
This should be a known issue on the Developer Community:
代码Azure DevOps Server中缺少"coverage"选项卡
MS小组答复:此问题的修复程序已在内部实施,正准备发布.
作为解决方法,您可以尝试使用jingzhu yan提供的方法:
As workaround, you can try the method provided by jingzhu yan:
希望这会有所帮助.
这篇关于ReportGenerator缺少代码覆盖率选项卡(Azure DevOps Server 2019.0.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!