Created
August 3, 2021 07:34
-
-
Save atlefren/cabbcc57870e913a4f362b0395285826 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Adding code coverage to Azure Devops, inspired by https://dejanstojanovic.net/aspnet/2020/may/setting-up-code-coverage-reports-in-azure-devops-pipeline/ | |
# Run tests, add "collect" option | |
- task: DotNetCoreCLI@2 | |
displayName: 'Run tests' | |
inputs: | |
command: test | |
projects: '**/*Tests/*.csproj' | |
arguments: '--configuration $(buildConfiguration) --collect "XPlat Code coverage"' | |
#Install the tool reporter. Use "update", not "install", as install fails if tool is installed | |
- script: 'dotnet tool update --global dotnet-reportgenerator-globaltool --version 4.5.8' | |
displayName: 'Install ReportGenerator tool' | |
#generate coverage reports in cobertura format | |
- script: 'reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura"' | |
displayName: 'Create reports' | |
#publish code coverage report as artifact of pipeline | |
- task: PublishCodeCoverageResults@1 | |
displayName: 'Publish code coverage' | |
inputs: | |
codeCoverageTool: Cobertura | |
summaryFileLocation: '$(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment