I have a header only library, lets call it lib.hpp
, and multiple test files that import it and call some functions from it, lets call them test1.cpp
through test10.cpp
.
I am using CMake, and creating tests with add_test(...)
for every one of these files, and then running them with CTest
I want to generate a coverage report using gcov and lcov for lib.hpp
that can show me the coverage from all the test files combined.
A .gcda file is generated in the for every test executable and I am looking for a way to combine everything into one coverage report that will measure code coverage of the lib.hpp
that is included in all test files
I am aware that CTest has a built-in code coverage functionality. I can invoke it with ctest -T Test -T Coverage
and output will be something like:
...
Total Test time (real) = 7.89 sec
Performing coverage
Processing coverage (each . represents one file):
...........
Accumulating results (each . represents one file):
............
Covered LOC: 834
Not covered LOC: 45
Total LOC: 879
Percentage Coverage: 94.88%
However, I am looking to generate a classic coverage report with lcov and gentml which I will later export somewhere, where I can actually open it and see what lines are being executed (here I can only see the coverage % in the last line)
For my use case, it is acceptable to run gcov commands manually, without relying on CMake, but as stated above, I do not know how to combine all the .gcda files into one coverage report
Edit: This question was automatically closed because it was deemed similar to this question, but these are completely different questions. What I am asking about here is about aggregating data