C Code Coverage Not Displaying

  • SonarQube Scanner v5.0.1.3006
  • Executed in a Docker Container via Github Actions

I’m trying to get a code coverage report generated using gcovr (v7.2) for c source files. I’ve added the path to the xml file in sonar.coverageReportPath. This is the output in my Github Actions logs:

...
------------- Run sensors on project
INFO: Sensor Generic Coverage Report
INFO: Parsing /mnt/coverage/coverage.xml
INFO: Imported coverage data for 2 files
INFO: Sensor Generic Coverage Report (done) | time=28ms
INFO: Sensor Analysis Warnings import [csharp]
INFO: Sensor Analysis Warnings import [csharp] (done) | time=0ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=11ms
...

Dashboard shows coverage as empty. I can see the coverage manually using other formats (e.g., html, text, etc) so I’m unsure what’s wrong here.
I’ve attached the xml file that was generated (renamed to .txt to be able to upload)

coverage.txt (16.3 KB)

Hey there.

What version of SonarQube are you using? You can find this in the footer of your SonarQube instance.

Version 10.3 (build 82913)

Thanks.

By all means, it looks like it should have worked.

  1. So, I had the -X flag enabled already and didn’t get any new info.

  2. I don’t believe I’m using a community supported plugin. This what I see at the bottom of the dashboard:
    Screenshot 2024-07-19 at 11.03.57 AM

  3. I see this on SonarQube once the xml file is uploaded (on a test branch):

So it looks like coverage is being imported for your project! But your test branch doesn’t have any new lines to cover. This can happen when you’ve only changed configuration files, or other files that can’t be covered by tests (think XML files).

If you should be seeing new lines to cover (new code that can be covered by test), that’s a different problem. But if not, then I think after merging your coverage config into your main branch, you should see that 5.3% after merge figure. Is that not the case?

That is not the case. After the branch was merged, total coverage is still at zero:

I’m generating my coverage reports using gcovr. I’m able to see the coverage with other output forms on this test branch and other branches. For example:

Is there an external tool that I can use to simulate/verify the xml file? Maybe it’s being generated incorrectly.

That’s really weird to see a 5.3% after merge figure on your PR, but not on your main branch. With the same coverage file being imported, these statistics should be identical.

Could you share:

  • The full analysis logs (sonar-scanner -X) of your main branch
  • A copy of the coverage report that is being imported for your main branch?

It also looks like this PR analysis was run a while ago. If you run it again, do you get the same estimated after merge figure?

I think your original assessment was correct.

This can happen when you’ve only changed configuration files, or other files that can’t be covered by tests (think XML files).

New PRs are showing coverage expectations.
E.g.,
Screenshot 2024-08-21 at 3.36.14 PM
Screenshot 2024-08-21 at 3.36.08 PM
Screenshot 2024-08-21 at 3.36.03 PM

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.