Code coverage reporting facility in SonarQube

We have SonarQube developer edition setup and we want to enable/get the Code coverage reports for our C,C++ codes . Kindly please let me know how i can have that in sonarqube. and also as part of jenkins build process.

Thank you.

Hi,

The docs should get you started.

 
HTH,
Ann

Hello @ganncamp , Thanks for the document.

I have generated the coverage_report.xml file with third party tool squish coco.
but while importing sonarqube is not reading the file.

my question is Is this possible to import coverage_report.xml generated by squish coco into sonarqube ? if possible how we have to provide the path.

Thank you

Hi,

You’ll need to get your reports into a format SonarQube recognizes. The docs should give you a starting point.

 
HTH,
Ann

Hi @ganncamp , as per the details mentioned in the docs(Test Coverage & Execution | SonarQube Docs), I have added the setup to generate the coverage reports with a third party tool and to export to SonarQube server.

  1. We are using the Sqish COCO tool and generated cobertura format xml reports
    Coverage_Report.xml
    24.156% (31888/132009)
    + echo ====Report created with cmreport====
    ====Report created with cmreport====
    2)Once the report Coverage_Report.xml generated and next step i have added sonar scanner
    properties to upload the report as below
    sonar.projectKey=test
    sonar.sources=${WORKSPACE}/src
    sonar.host.url=http://soarqube-server/
    sonar.login=************************
    sonar.c.file.suffixes=-
    sonar.cpp.file.suffixes=-
    sonar.objc.file.suffixes=-
    sonar.branch.name=dev
    sonar.cxx.coverage.overallReportPath=${WORKSPACE}/Coverage_Report.xml
    sonar.projectVersion=1.0
    sonar.sourceEncoding=UTF-8

3)As this setup is in jenkins and i could see a log message that the reports are uploaded to sonarqube server
11:39:24.184 INFO: Analysis report uploaded in 482ms

Issue : I logged in to sonarqube server but i am seeing code coverage is empty, please have look at the image attached .

Please let me know if any configuration i need to add, Thank you.

Hi,

The cxx plugin is not supported in this community. If you have issues using it, you need to direct your questions to its maintainers.

Thanks for understanding.

 
Ann

Hello @ganncamp
I am not using the CXX plugin, looks like i coped the wrong command .
the one which i used is sonar.coverageReportPaths=${WORKSPACE}/Coverage_Report.xml

  1. My question is is it possible to upload Cobertura-XML reports to SonarQube server?

  2. could you please let me know how i can address this task for uploading sqish coco generated
    Cobertura-XML/ XML reports to SonarQube dashboard and check for code coverage

Hi,

What language are we talking about? Cobertura reports are supported for Flex and Python. On the other hand, the parameter you’ve cited, sonar.coverageReportpaths, is for passing a report in the Generic Test Data format. The docs may help.

 
Ann

@ganncamp
I am looking for c and c++ codes. is sonarqube support Cobertura-style reports for C or C++ generated with third-party tool.

  • I don’t see much details on having third party generated report published in sonrqube server .
  • If the reports are in xml i guess it will not be successful to get coverage in sonarqube.
  • As its mentioned in document it should be .XSD file . I think i have to conver final XML to .XSD right?
  • I can covert but again it will be a additional tool/software required .

Hi All,
We have a SonarQube Developer edition subscription and exploring on coverage option in soanrqube. we have a third-party tool Sqish coco to generate reports and wanted to import that report to SonarQube server .

  • We are generating code coverage report in xml format using the third-party tool Sqish COCO for C and C++ codes. Report formats supported by the tool are 1)text 2)HTML, 3)EMMA-XML,4)Cobertura.

  • From the Sqish coco official document its mentioned that “SonarQube – Integration with the quality platform SonarQube is available via the Cobertura XML output format”
    link : doc
    Mode details on soanrqube and coverage report integration : Part VIII  Other Coco Tools

I have tried all the possible ways but still the coverage option in sonarqube shows empty .

From the SonarQube document i see that converting the document to generic XSD format should work. Even i tried this also but still it does not worked .

Let me know how we can have this coverage working.

Thank you,

Hi,

I’ve moved your new thread into this one because it was the same content and needs the same answer.

Your 3rd-party tool generates a Cobertura format, but SonarQube doesn’t support the Cobertura for C and C++. You’ll find the supported formats in the docs: GCov, LLVM, VS Coverage, and Bullseye.

If you’ve been misled by the Sqish coco official documentation, then you should take that up with the Sqish coco folks.

 
Ann