Test coverage

When we discuss tests, it's quite common to hear the term test coverage. This is a measure used to check how much code is being executed by the suite tests, and it's helpful for determining what alternative paths of code are not tested and are hence prone to bugs.

Let's suppose that you are writing a method that has an if statement. In that case, your code has two alternative paths to follow; so, if you want to achieve 100% coverage, you will need to write tests to validate all of the alternative routes that your code can follow.

There are many useful libraries available for measuring the coverage that code has. In this chapter, we are going to introduce one of the most popular libraries in the Java world; the library is called ...

Get Software Architecture with Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.