Chapter 5. Exploring Code Coverage

This chapter explains the code coverage, coverage tools, and provides step-by-step guidance to generate a coverage report.

The following topics are covered in this chapter:

  • Code, branch, and line coverage
  • Coverage tools such as Clover, Cobertura, EclEmma, and JaCoCo
  • Measuring coverage using Eclipse plugins
  • Using Ant, Maven, and Gradle to generate reports

Understanding code coverage

Code coverage is a measurement of percentage of instructions of code being executed while the automated tests are running.

A piece of code with high code coverage implies that the code has been thoroughly unit tested and has a lower chance of containing bugs than code with a low code coverage. You should concentrate on writing meaningful ...

Get Mastering Unit Testing Using Mockito and JUnit 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.