Skip to content

Building with code coverage

offa edited this page Mar 17, 2016 · 4 revisions

The project can build with code coverage using lcov. This feature is optional and off as default.

Code coverage is only supported in Debug-mode.

1. Requirements

For code coverage lcov is required.

2. General

In general generating coverage files requires following steps:

  1. Building with coverage enabled
  2. Running tests
  3. Use make coverage to generate coverage data

In a nutshell:

mkdir build
cmake -DCOVERAGE=ON ..
make
ctest
make coverage

Note: If no build type is specified and coverage enabled Debug will be set.

2.1 Enabling code coverage

The code coverage is enabled through the COVERAGE option.

COVERAGE
ON Enable coverage
OFF Disable coverage (Default)

This is usualy enabled using the -D<OPTION>=<VALUE> switch (or using the GUI):

mkdir build
cmake -DCOVERAGE=ON ..
make

2.2 Running tests

Running tests:

ctest

or:

make test

2.3 Generating coverage files

Finally

make coverage

is used to generate coverage files. The files are created within the build directory in coverage/.

2.4 Resetting counters

To reset the counters, make coverage-clean can be used.

Example:

make coverage-clean && make unittest && make coverage

Clone this wiki locally