I have a .net core project with pipeline (YAML, multi-stage) pipeline set up in Azure DevOps. We have a bunch of unit tests that we execute at pipeline run time - everything is fine.
However - we would like to dig more deeper into our code coverage. So we have configured our task like this
- task: DotNetCoreCLI@2
displayName: Run UnitTests
enabled: true
inputs:
command: test
projects: '**/PM.UnitTests.csproj'
arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
The result is this
We can now see this in pipeline results:
This .coverage file can be downloaded and analyzed in e.g. Visual Studio.
However - we would really like to be able to see the results directly in Azure Pipelines. We have a Typescript project where we do this. The result is this:
Sadly, it is not at all apparent to me how to apply this to a .net core project.
Q1: Is it possible to have the same experience for .net core projects ... and how?
Additionally - we would like to be able to apply filtering on which parts of the code is used to calculate the code coverage percentage.
Q2: Is it correctly understood that this is done using a .runsettings file?
Thank you :-)
/Jesper
For reference, this is my complete YAML pipeline in my test .net core solution. The solution is super simple - a .net core class library and a .net core test class library
pool:
vmImage: vs2017-win2016
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
feedsToUse: 'select'
vstsFeed: 'd12c137f-dac4-4ea7-bc39-59bd2b784537'
- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: '**/*.csproj'
arguments: --configuration $(BuildConfiguration) --no-restore
- task: DotNetCoreCLI@2
displayName: Run UnitTests
inputs:
command: test
projects: '**/Test.Coverage/Test.Coverage.csproj'
arguments: '--configuration $(BuildConfiguration) --collect:"XPlat Code Coverage" '
- script: 'dotnet tool install -g dotnet-reportgenerator-globaltool '
displayName: 'Install dotnet-reportgenerator-globaltool'
- script: 'reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(build.sourcesdirectory) -reporttypes:"Cobertura"'
displayName: 'Executes reportgenerator'
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage from $(build.sourcesdirectory)/Cobertura.xml'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(build.sourcesdirectory)/Cobertura.xml'