Skip to content

Integration of Catch, CMake and CMake CodeCoverage module and basic examples in C++.

License

Notifications You must be signed in to change notification settings

claremacrae/catch_cmake_coverage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmake_catch_coverage

Integration of CMake, Catch and CMake CodeCoverage module for C++ code. (CMake CodeCoverage depends on: gcov, gcovr, genhtml, lcov.)

Setup

install test build environment tools (Ubuntu)

./setup.sh

Usage

test build and test execution (with junit format .xml result piping into build/unit_test_result.xml, without coverage analysis)

cd build/
cmake ..
make unit_tests
./unit_tests -r junit > unit_test_result.xml

test build, test execution (with coverage analysis) and coverage observation

cd build/
cmake .. -DENABLE_CODE_COVERAGE=on
make unit_tests_coverage
xdg-open ./unit_tests_coverage/index.html

Clare Macrae's extra notes

Generating branch coverage

Based on this question, you need to have the following lines enabled in your ~/.lcovrc file:

genhtml_branch_coverage = 1
lcov_branch_coverage = 1

On a Mac, with lcov installed via brew, you will want to look at /usr/local/etc/lcovrc, not /etc/lcovrc

See the reference docs: lcovrc - lcov configuration file.

Excluding Catch2 test macros from the branch coverage

Add this to your ~/.lcovrc file:

lcov_excl_br_line = LCOV_EXCL_BR_LINE|CHECK|REQUIRE

About

Integration of Catch, CMake and CMake CodeCoverage module and basic examples in C++.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published