Improve Your Testing #11: Breaking through the barrier of 100% code coverage

Why mocks and good design matter more than chasing percentages.

David Rodenas PhD

--

Prompted and edited by the author.

In the previous installment, I explained everything we can learn from code coverage, and I even explained how through code analysis we could detect and add those cases we had missed. However, despite appearances to the contrary, we cannot completely cover the code with 100% code coverage. Why?

Why isn’t 100% required?

We must have observed that many companies usually require a minimum code coverage. This minimum typically hovers around 80%. The question is, if they consider code coverage so important, why don’t they require 100%?

The first reason they’ll give us is cost. 100% code coverage requires very thorough testing and, therefore, means that developers will spend more time writing tests than developing code.

This goes directly against what I teach in these pages.

To begin with, this view of testing cost comes from the fact that tests are written after the code is written. They’re expensive because they need to be adapted to the code, and they’re expensive because, as we’ve seen in previous articles, they don’t provide any additional value. They even increase future…

--

--

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.

Responses (8)