What is and how do we measure code coverage?

Test quality is very important and one of the most important things in building quality tests is to cover all production code lines with tests.

Code coverage is a metric that shows us the percentage of code that is covered by tests. Using test coverage we can also identify the lines of code that we missed.

Using IntelliJ Idea to check for code coverage

All modern IDEs have a tool that allows us to run tests with code coverage. This way we will be able to see what methods and lines of production code we didn’t cover and write more tests before pushing the code into a repository.

Another great way to check code coverage is to use a tool like SonarQube.

Covered lines are green and uncovered are red

1 thought on “What is and how do we measure code coverage?”

  1. Pingback: Testing Spring Boot applications

Leave a Comment

Your email address will not be published. Required fields are marked *