To collect C++ test coverage metrics with C++ Community Plugin, you have to:
- Create a coverage report (or many of them) using a coverage tracer like Gcov (see Coverage tracers)
- Configure your project to point to the report and rerun the analysis
Three types of test coverage are supported: Unit, Integration and Overall coverage. Use one of the following configuration properties dependent of the coverage type (see also Configuration for details):
- sonar.cxx.coverage.reportPath for unit test coverage
- sonar.cxx.coverage.itReportPath for integration test coverage
- sonar.cxx.coverage.overallReportPath for overall test coverage
Notes about coverage display in SonarQube
SonarQube <3.2 provides metrics for line coverage and branch coverage. Bullseye users have function and branch/decision coverage instead. The C++ Community plugin converts the second directly into branch coverage however line coverage is far more complex and cannot be correlated directly into function coverage.
Line coverage imported from a bullseye report means than function coverage + line branch coverage (this second occurs since SonarQube will not display branch coverage if there isn't a line it associated with it). This means also that overall coverage will be affected in SonarQube and cannot be compared directly to bullseye results. The following pictures illustrate this for a small example project.