0

I need to generate the test coverage report and I have observed that when all the google testcases gets passed then only GCOV generates the coverage report. But now few of the testcases are getting failed. Is there any way to generate test coverage report with failed testcases?

Platform details :
OS - Ubuntu 18.04
Language - C++17
Test framework - Google test (gtest) Cmake - v3.21.2

Here is the screenshot of the error.

enter image description here

Kindly suggest.

Thanks.

  • What do you mean by the tests failing. Do they crash (e.g. segfault), or do they exit normally (just with non-zero exit code)? Are you sure that the gcda files are not being created by the tests? – amon Aug 24 '21 at 15:07
  • Test failing means if there is a condition such as `EXPECT_EQ(1,2)`, this gets failed and exits normally with a non-zero exit code. Yes, gcda and gcno both files are getting generated successfully. – Shital Jadhav Aug 30 '21 at 08:05
  • Then there's nothing preventing gcov from working. This is likely a case where your build system won't run the “coverage” step if the previous “test” step failed. What build system (e.g. CMake) are you using to run the tests and the coverage tools? – amon Aug 30 '21 at 11:50
  • Cmake version is 3.21.2 and I have attached screenshot in the description pls. check it. – Shital Jadhav Aug 30 '21 at 12:14
  • Yes, this looks entirely like a build system problem. CMake thinks: “To `make gcov` I first have to `make test`. Oh no, running the tests failed, so I can't run the coverage command”. This is actually somewhat reasonable: the build system doesn't know whether the tests failed because of a failed EXPECT, or because the testing process itself is broken. If you want to change this, it might be best to ask a separate question about configuring a suitable coverage target with CMake. – amon Aug 30 '21 at 16:24
  • Yes, exactly the situation is with CMake. By using individual commands coverage report is getting generated. Could you please suggest me the solution for this? – Shital Jadhav Aug 31 '21 at 06:41
  • Sorry, I'm not sufficiently familiar with CMake to fix this. A new question under the [tag:cmake] tag might help. – amon Aug 31 '21 at 09:08

0 Answers0