SonarQube not showing code coverage for OpenCppCoverage with export_type=cobertura

  • using, sonarqube-9.4.0.54424 developer edition and sonar-scanner-4.7.0.2747-windows
  • My project is having C, C++ languages. I am able to run sonar-scanner and results are shown on dashboard using build-wrapper-win-x86.
    But the coverage is showing zero.
    I am using googletest for unit test cover and creating code coverage report in cobertura (xml) formal using OpenCppCoverage.
sonar.coverageReportPaths=./ctestCoverage.xml
sonar.cobertura.reportPath=./ctestCoverage.xml
sonar.flex.cobertura.reportPaths=./ctestCoverage.xml

  • I tried above things but for 1st line throwing parsing error and remaining lines are not reflecting in logs.
ERROR: Error during SonarScanner execution
ERROR: Error during parsing of the generic coverage report 'C:\REPO\ctestCoverage.xml'. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: Unknown report version: 0. This parser only handles version 1.

Is there any way to support cobertura xml for c++ project or any option to generate sonar supported report using OpenCppCoverage?

Thank you

Welcome to the community, @pratikmhatre!

Thank you for the report, I have checked OpenCppCoverage, and the tool support exporting in Cobertura and internal binary format. We currently do not support importing either of them.

One possibility would be to convert them into the generic coverage format and provide a path to the report as sonar.coverageReportPaths. Note that this property accepts reports in this format. Providing a report in another format will cause an error that you are encountering, so you should remove this line unless the report format is transformed.

Regarding other options:

  • sonar.cobertura.reportPath is not recognized by our analyzer and seems to be used by following thirdParty plugin.
  • sonar.flex.cobertura.reportPaths applies only to code in the Flex language and it does not apply for C++ code