Reputation: 1
I am trying to write YAML file for code coverage.
What is the correct way to get code coverage for my project in Azure pipelines using coverlet and cobertura configurations?
I have followed the same steps as running locally with CLI commands, but I am still getting zero coverage. My arguments are as follows:
--configuration $(buildConfiguration) --collect:"XPlat Code Coverage" --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Exclude="[xunit.*]*" /p:CoverletOutput=$(System.DefaultWorkingDirectory)\coverage.
Should I exclude my project while running the code coverage command? Any ideas on what might be wrong with my commands?
I tried all the steps found on internet. I verified commands comparing with the commands running locally in CMD with same commands.
Upvotes: 0
Views: 1240
Reputation: 8127
I can reproduce with same arguments for dotnet test
:
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: 'test'
arguments: '--configuration Release --collect:"XPlat Code Coverage" --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Exclude="[xunit.*]* /p:CoverletOutput=$(System.DefaultWorkingDirectory)\coverage'
For Xplat Code Coverage
, you need to add PublishCodeCoverageResults@2
task after the test task, so that it will publish the coverage from the build.
- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: |
$(Agent.TempDirectory)\**\coverage.*.xml
Note: checked on my side, even you have specified /p:CoverletOutput, it will still generate the coverage.cobertura.xml in $(Agent.TempDirectory) folder.
Upvotes: 0