tabs
tabs

Reputation: 1

How to get Code Coverage Report on Sonarqube for C++ library

I am trying to display code coverage for my project in sonarqube. The closest I got so far is that it shows the coverage on header files, but not on source files.

My Setup: I have a project with multiple modules and want to get the coverage for a C++ library (as a CMake-project). The unit tests are implemented with googletest and the build pipeline is executed on a Jenkins server.

This is what I tried: I ran gcovr --keep or gcov *.o and put in the sonar-project.properties my-module.sonar.cfamily.gcov.reportsPath=path-to-gcov-files. (Unsurprisingly,) I got the same result for both. Sonarqube shows some code coverage, but only for header files. In the sonarqube logs I see Sensor gcov [cpp] and some lines about what it does.

I ran gcovr --sonarqube coverage.xml and put in the sonar-project.properties my-module.sonar.coverageReportPaths=./coverage.xml. This gives no coverage result in sonarqube and I can't find anything in the logs related to this. However, when I just run gcovr I get coverage result for both header files and source files, I just don't know how to transfer this to sonarqube.

Can anyone tell me what I am doing wrong?

Upvotes: 0

Views: 1001

Answers (1)

user27550312
user27550312

Reputation: 1

  1. check the relative path in the sonarqube vs relative path in the file.
  2. convert the cobertura coverage.xml format to sonar xml format, I have done that manually by using python code

Upvotes: 0

Related Questions