7

I am using googletest to test my C project. Now, I added gcov to check the coverage of the unit tests. This all works fine.

When looking at the coverage of the Conditionals in my code, my coverage rate drops significantly. I analyzed the coverage results and found out, that all my assertions are marked as not covered in terms of conditionals, i.e. the assertion failures.

I figured, this might have to do with my death tests (ASSERT_DEATH()). Since googletest spawns a new process for every death test, I assume that they are not "tracked" by gcov.

However, I would like to see in my coverage results, if my tests actually cover both conditions of my assertions. Is there a way, I can tell this to gcov or googletest?

I already tried setting googletest flags, such as --gtest_throw_on_failure, but without success.

lmNt
  • 3,822
  • 1
  • 16
  • 22
  • Have you tried this: http://stackoverflow.com/questions/28408811/how-do-i-generate-coverage-reports-for-forkd-children-using-gcov-lcov – Bug Killer Feb 03 '16 at 21:18
  • 1
    @BugKiller Thanks for the hint. But I'm not quite sure, how I should incorporate that into my death tests, since I can not control gtest kills the forks... or can I? – lmNt Feb 22 '16 at 09:13
  • Any progress on the topic? – user362515 Dec 06 '22 at 13:32
  • 1
    Sorry @user362515, I've not pursued this further. The only solution I could come up with was to 'relay' the death test macros (e.g. `ASSERT_DEATH()`) into a custom one that would not fork the gtest process and instead let the process die naturally from the assertion and thus tracking coverage through that. Then you'll have to make sure that you run each of those death tests individually as a separate process (cause they die) and track coverage through that. I thought that was too much of a hassle for just a coverage metric. – lmNt Dec 21 '22 at 14:23

0 Answers0