[Code coverage & Quality]– The Duty of Developer as a Professional #4

Linh NGUYEN
3 min readNov 13, 2019

--

"As a quality fanatic,

When I receive the code coverage report,

I want to see 100% overall"

Every project, at a moment, has one of these states:

  • Good code coverage — bad quality
  • Bad code coverage — bad quality
  • Bad code coverage — good quality
  • Good code coverage — good quality

How is code coverage related to quality (or not) then?

How code coverage can be achieved?

“Code coverage is the percentage of code which is covered by automated tests. Code coverage measurement simply determines which statements in a body of code have been executed through a test run, and which statements have not.”

- Clover support page

Good code coverage can be achieved either with a well designed and testable code base or even with a messy “spaghetti” one.

Bad code coverage is the result of either poorly-implemented tests, not enough tests or even no tests at all.

⚠️This image is hilarious and realistic. However it does not reflect all…

Here is why:

  • Good code coverage” does not mean “All code well tested”.
  • Good code coverage” does not mean “Tests well implemented”.
  • Code coverage helps a developer to detect if there are still risks that may decrease the quality of his work. A “bad code coverage” can show that the code is not all covered and there may still be some missing cases… A “Good code coverage” tells that the code is well covered, but it does not mean “No defects/bugs”.
  • Code coverage helps a developer to finalize his work. There is however no guarantee if the business requirements are correctly fulfilled.
  • There is also no assurance for the performance of the code. As tests in general verify if the outputs is correct for given inputs, un-optimized code and optimized code, both can pass the tests.

Good/bad quality, of what?

“Quality is the standard of something when it is compared to other things like it; how good or bad something is”

- Oxford Learner’s Dictionary

In fact, what represents quality is different depending on which responsibility one holds within a project.

For Developers

Quality, for developers, is not about the code coverage, but about how to make the code designable and testable.

For the following responsabilities, the quality is only about the product, eg: app, software, website…

For QA (Quality Assurance) team members

Quality, for QA-s, we would say it is defined by bug reports. The number of bugs found and their criticality level indicates if the features are well implemented.

For the Company

Quality, for the Company, is the sum of the QA approval and user's positive feedbacks.

Conclusion

Code coverage is a useful metric that can help developers estimate the quality of the test suite (not the source code, not the final product). Comparing or matching Code coverage & Quality is irrelevant.

(source: martinfowler)

Code coverage, for whom ?

For Professional Developers, of course.

Should code coverage be matched with code’s quality?

Not really.

Should code coverage be matched with bug reports?

No.

Should code coverage be matched with business quality?

No.

Should code coverage be matched with customer’s satisfaction?

No.

Co-writting with Mohammed HIMOUD and Abderrahim Benmakhlouf

We hope that you learned something today with this post ! Give us claps if you liked it :)

--

--