Code Coverage not being shown after bitbucket pipeline build

  • ALM used (Bitbucket Cloud)
  • CI system used (Bitbucket Cloud)
  • Scanner command used when applicable
dotnet-sonarscanner begin /k:"${SONAR_PROJECT_KEY}" /d:"sonar.token=${SONAR_TOKEN}" /d:"sonar.host.url=https://sonarcloud.io" /d:"sonar.cs.vscoveragexml.reportsPaths=coverage.xml" /o:"xxxxxxxx"
dotnet restore
dotnet build
dotnet tool install --global dotnet-coverage
dotnet-coverage collect "dotnet test -c Release -f xml -o "coverage.xml"
dotnet-sonarscanner end /d:"sonar.token=${SONAR_TOKEN}"
  • Languages of the repository: C#

I have started using sonar cloud with bitbucket pipelines for our .NET Core applications. My pilot demonstration with a small project worked well. I was able to get the analysis and code coverage working.

However when I tried to use the same strategy for a larger microservice for reasons I cannot determine, the code coverage is not being uploaded to the cloud service. I wouldn’t consider the project large overall, its a .NET Core WebApi microservice with about 8 end points, its just bigger than the other that worked.

The build is successful here are the last few lines of the report

INFO: Sensor C# [csharp]
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/1/output-cs'
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/6/output-cs'
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/4/output-cs'
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/9/output-cs'
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/0/output-cs'
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/5/output-cs'
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/3/output-cs'
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/8/output-cs'
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/2/output-cs'
INFO: Importing results from 6 proto files in '/opt/atlassian/pipelines/agent/build/.sonarqube/out/7/output-cs'
INFO: Importing 10 Roslyn reports
INFO: Found 5 MSBuild C# projects: 4 MAIN projects. 1 TEST project.
INFO: Sensor C# [csharp] (done) | time=675ms
INFO: Sensor Analysis Warnings import [csharp]
INFO: Sensor Analysis Warnings import [csharp] (done) | time=2ms
INFO: Sensor C# File Caching Sensor [csharp]
INFO: Sensor C# File Caching Sensor [csharp] (done) | time=29ms
INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Parsing the Visual Studio coverage XML report /opt/atlassian/pipelines/agent/build/./coverage.xml
INFO: Adding this code coverage report to the cache for later reuse: /opt/atlassian/pipelines/agent/build/./coverage.xml
INFO: Coverage Report Statistics: 144 files, 139 main files, 139 main files with coverage, 5 test files, 0 project excluded files, 0 other language files.
INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=687ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=1ms
INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 5 source files to be analyzed
INFO: SCM Publisher 5/5 source files have been analyzed (done) | time=92ms
INFO: CPD Executor 19 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 133 files
INFO: CPD Executor CPD calculation finished (done) | time=30ms
INFO: SCM writing changed lines
INFO: SCM writing changed lines (done) | time=80ms
INFO: Analysis report generated in 568ms, dir size=495 KB
INFO: Analysis report compressed in 172ms, zip size=227 KB
INFO: Analysis report uploaded in 790ms
INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=xxxxxxxxxxxxxxxxxx&pullRequest=76

However the sonar cloud report has no code coverage.

Is there anything I am missing in my configuration?

Hey there.

I think you’re facing an issue we plan on fixing soon, where PRs with 0 New Lines to Cover don’t show coverage information.

Can you check the Measures > Coverage section of your PR to see if you have any lines to cover?

If there are 0, it probably means you have everything configured correctly (and it will work on the main branch), and you’re just facing a display issue we have in the backlog.

Hi Colin

Thanks very much for the reply it does look my coverage is 0 for new lines. Good to know that a fix is on the way. Let us know when its ready.

image

Thanks,
Zane

1 Like