Enable coverage and add Howto for coverage

Updated CMakeLists.txt to enable coverage.
Updated instructions with howto for coverage and also a separate
set of instructions how to run during a TDD cycle with coverage.
This commit is contained in:
msiverback 2022-10-17 08:42:57 +02:00 committed by martin.siverback@combitech.com
parent 760fa27d4a
commit c54cdfbb5b
2 changed files with 14 additions and 2 deletions

View File

@ -28,8 +28,8 @@ endif()
# Bring the populated content into the build
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
# uncomment this line to enable coverage measurements using gcov
# set(CMAKE_CXX_FLAGS "--coverage")
# comment this line to disable coverage measurements using gcov
set(CMAKE_CXX_FLAGS "--coverage")
enable_testing()
add_subdirectory(src)

View File

@ -49,6 +49,18 @@ The `GildedRose.cc` file, i.e. the code under test, is identical in all four var
$ ctest -VV --tests-regex Catch2Approval
## How to run with test coverage
1. go to build directory
2. Run:
$ lcov --directory ./ --capture --output-file ../lcov.info -rc lcov_branch_coverage=1
3. in bottom right corner of VS Code press "Watch"
3. Coverage will now be visible in VSCode.
## How to run during a typical TDD cycle
$ cmake --build .
$ ctest -VV --tests-regex GildedRoseGoogletestUnitTests
$ lcov --directory ./ --capture --output-file ../lcov.info -rc lcov_branch_coverage=1
## How to build and run tests using the [CLion IDE](https://www.jetbrains.com/clion/)
1. Start CLion