Skip to content

Get code coverage metrics

Günter Wirth edited this page May 11, 2014 · 23 revisions

It is not all the same

Talking about coverage the most important question is: what coverage your are talking about. There are different kinds of coverage measurement and each tool has a slightly different way doing it and displaying the results. If you are looking for a very good introduction read Code Coverage Analysis on the Bullseye page.

Setup the C++ Community Plugin

To collect C++ test coverage metrics with C++ Community Plugin, you have to:

  1. Create a coverage report (or many of them) using your favorite coverage tracer (see Coverage tracers for examples)
  2. 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 Supported configuration properties 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

The C++ Community plugin accepts two different formats for the test coverage reports, which will be recognized automatically:

TODO @guwirth: ms code coverage additions

Notes for BullseyeCoverage users:

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 illustrates this for a small example project.

Coverage visualisation for Bullseye users

Clone this wiki locally