Search code examples
code-coveragesonarqubecobertura

How to import C++ Cobertura coverage reports into Sonar?


I am writing a tool that would generate Cobertura coverage reports for C++ projects. I have managed to generate the reports and now I would like to import these reports into Sonarqube.

I noticed that the Sonar C++ Community Plugin supports the Cobertura XML format so I downloaded a sample C++ project for that plugin and executed sonar-runner and the execution is succeeding, however the Unit Tests Coverage section for the project in the the Sonar server's web front end contains no information (just a dash '-' symbol, indicating nothing).

What am I doing wrong? Why can't I see any information from the imported Cobertura covreage report?

Thanks in advance.


Solution

  • It turns out that the most recent gcovr version (3.1-prereleas) changes the way Cobertura reports are generated in that it the class tag's filename attribute contains the source code file's name only and not it's project root-relative path.

    The problem can be solved either by using an earlier gcovr version (I tried 2.4 and it worked) or by manually modifying the report to make it compatible with the C++ plugin's Cobertura parser again.