Skip to content

Generate code coverage reports

Michael Hall edited this page May 14, 2019 · 6 revisions

Dependencies

You need to have lcov installed.

Additionally, these instructions will be focused on running tests from CLion. If you are running from command line it should be a very similar process.

Clear previous counter

The first thing you need to do each time is clear the output from the previous coverage counters.

cd /path/to/pandora
cd cmake-build-debug/test/CMakeFiles/pandora_test.dir
lcov --directory . --zerocounters

Run tests

Run the test suite from CLion.

Capture coverage information

lcov --directory . --capture \
  --exclude '/usr/local/include/boost/*' \
  --exclude '*_test.cpp' \
  --exclude '*.h' \
  --exclude '/usr/include/*' \
  --exclude  '*cmake-build-debug*' \
  --exclude  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/*' \
  --output-file pandora_test.info

lcov on your system may or may not raise an error with the --exclude arguments as these may have different paths to your system. You can remove them if you want but keep in the mind the coverage report will contain a bunch of other files not related to pandora. For example, if using Linux, you wont need to exclude the Xcode directory.

Generate the report

genhtml --show-details --legend pandora_test.info

And then open the index.html file generated in that directory.

Clone this wiki locally