An important note regarding code coverage

Let’s first consider what code coverage means.

It is a measure of how much of a software application’s source code is executed during testing. The higher the code coverage, the more thorough the testing. The code coverage is typically measured as a percentage, with the goal being to achieve as close to 100% coverage as possible. There are tools available to help programmers to set % gates in CI/CD pipelines (e.g. SonarQube), analyse the code and determine which lines of code have been executed during testing.

Many people talk about code coverage, it’s so important. However, there is one detail.

A detail that caught my attention a few years ago:

The code coverage might be an indicator, but it would not be considered as a metric of Code Quality.

It’s important to keep asking yourself, if you are testing the right stuff. Keep asking the following question:

Are we investing in the right places in our test coverage?

Ignoring how much of your code you are testing can cause you to let buggy code slip through the cracks.

Happy coding, regards,

Łukasz.

// Photo by Nikita Kachanovsky on Unsplash