Dilemma over authenticity of gcov generated code coverage percentage where unit tests are not technically correct #3463
Unanswered
harshilshah2501
asked this question in
Community Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When I joined my company as a new comer and I was exploring the unit test suite of the product code. It is using gtest framework. But when I checked all the tests, they were testing the whole functionality by calling real functions and asserting expected output. Below is one such test case as an example:
I found all the tests in the unit test directory having the same pattern like:
So, all the tests appear more of as functional or integration tests, rather than unit tests, which ideally should be testing about a particular unit or function code.
But, the critical part is, on their official intranet site, they have projected the code coverage percentage of this product as 73%, computed using gcov.
Now, code profiling tools like gcov computes coverage on the following params:
As, these tests are running actual daemon, loading real database and calling actual functions to scan the message including actual network (socket) calls. Of course, above 3 params will play some role in it, so I doubt the code coverage number will be completely zero, but in my opinion, it is not authentic.
As per my understanding, term code coverage is generally used with white box testing, as they are written by developers.
So my bothering question is:
Black box testing also does functional testing just as this, so what's the difference between above kind of test and functional test? In blackbox, testers unaware of the inside code, writes test cases to test the functionalities specific to requirements.
Apparently, test suite consists of all technically incorrect unit tests by its standard definition. Purpose of unit test is to test the code itself, by smallest unit wise. *So does gcov generated coverage on such test suite, can be trusted or reliable? [I honestly don't think so.]
This is haunting me for some time. So thought to serve on the table for experts.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions