Converting Cobertura coverage for C++ to Generic Test Coverage Report


So my coco job is outputting a cobertura-report.xml file which to my understanding is not compatible with SonarQube Enterprise 9.5. The documentation says that I can upload to Generic Test Format. I see in some other posts that there are converters, but I haven’t seen one for my case. Does anyone know of a tool that can convert my cobertura report to a SonarQube friendly format like Generic Test?

Language: C++
SonarQube Enterprise 9.5
Sonar Scanner Version:
Report type: Cobertura

Hi @joshgrady

Welcome to our community!

Can I ask which tool you are using to generate your coverage?
Is it possible that it has an option to generate the coverage to a format directly supported by SonarQube?


I have a similar problem.

I work on a C++ project built by MSVC and CMake and tests are written according to google tests.

The only option I found that matched the conditions above and worked for my case to get test coverage is using OpenCPPCoverage. It provides formats such as “Binary”, “Corbertura”, and “Html”.
So I have the same question, how I can convert my Corbertura test coverage result into a format readable by SonarQube?
coverage-report.log (144.1 KB)

Thanks and Best Regards,
Bijan Goshayeshi

Hi Geoffray,

Tracing back through my gradle file that controls a majority of the workflow I believe we use Squish Coco called through a python script.

# Create report from merged files
cmd = ["cmreport",
       "-m", merged_csmes_filename,
       "--html={0}".format(os.path.join(args.reportname, args.reportname)),

# Execute report generation
execute_cmd(cmd, outputdir)
print("Finished creating HTML report. You can find it in:\n"
      "  {0}.html".format(os.path.join(outputdir, args.reportname, args.reportname)))

# Get Cobertura paths
cobertura_xml = "{0}.xml".format(args.cobertura_reportname)
cobertura_path = os.path.join(args.reportname, cobertura_xml)
cobertura_source = os.path.abspath(args.cobertura_source)
# Create Cobertura report from merged files
cmd = ["cmreport",
       "-m", merged_csmes_filename,
# Execute Cobertura report generation
execute_cmd(cmd, outputdir)
print("Finished creating Cobertura report. You can find it in:\n"
      "  {0}".format(cobertura_path))

Beyond this I imagine I will need to look into squish coco parameters in their documentation and maybe find a away to specify an alternative format.

@bijan_goshayeshi and @joshgrady


It seems you are both in a somehow uncommon case we do not support.
Whereas Cobertura is a common coverage format for Java, it is substantially less so for C and C++.

You can vote for it there if you want to.

In the meantime, a solution for you is to convert your Cobertura coverage file to the Generic Test Coverage Report Format.
It seems that some xslt is available on GitHub (I never tried them).

We’re also using Squish Coco with the same problem. Is there any more current solution? The XSLT is GPL’d so I don’t want to integrate it into our codebase, and I don’t want to download it every time, creating a dependency on GitHub availability.

Hello @Carl

I am not aware of any other solution at the moment.
I take note of the pain with the licensing.
If you did vote for the Cobertura import feature, you’ll be notified when things get to move.

Hi @Geoffray

I actually found a solution in the meantime, using the sonar.cxx plugin you can add coverage, even when using the sonar cfamily sensor, because the new version of sonar.cxx uses the file extensions from the cfamily one as well.

It is quite painful to use though (e.g. can’t handle relative paths in Cobertura XML). So maybe an official solution would be better still.

Thank you for sharing your solution.
The pain is well-recorded.
You can vote for it there if you want to. You will then be notified of any progress on it.

Done, thank you!

Hello @Geoffray

Thank you for the hint about xslt. I just tried this tool, but unfortunately it did not convert properly my Cobertura coverage file. The converted file is practically empty:

<?xml version="1.0"?>
<coverage version="1"/>

I have similar environment to @bijan_goshayeshi - CMake/MSVC/OpenCppCoverage.

I already voted for the import feature. It would be really great to have it. I use SonarCloud, so I cannot use the plugin.


Best, Marcin