-1

I am using lcov and genhtml to generate code coverage reports. My unit test files only include the .h header files.

client_test.cpp

#include "gtest/gtest.h"
#include "../client.h"
...
lcov --capture --no-external --rc lcov_branch_coverage=1 --directory . --output-file unfiltered_coverage.info

I have noticed that the coverage report only contains coverage information for the files which were in the include section of my unit tests. Thus, the coverage report only contains the client.h file and not the client.cpp file.

Dev Sen
  • 37
  • 2

1 Answers1

-1

That makes sense because the coverage report will attach results relative to where functions were declared, not where they were implemented.

jhill515
  • 894
  • 8
  • 26
  • In that case, what would be the way to create the coverage for the implementation as well. – Dev Sen Apr 25 '19 at 17:00
  • Would I have to include the .cpp files in the test instead. – Dev Sen Apr 25 '19 at 17:25
  • It's only going to list based on declarations. Still, it'll count the branching and line coverage in the *.cpp files. The limitation to locations of declarations is so that there isn't misinterpretation nor added noise. – jhill515 Apr 25 '19 at 19:52