Book Image

Testing with JUnit

By : Leonard Przybylski, Frank Appel
Book Image

Testing with JUnit

By: Leonard Przybylski, Frank Appel

Overview of this book

Table of Contents (16 chapters)
Testing with JUnit
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Integrating code coverage reports


The last section will revisit and deepen the knowledge about the assets and drawbacks of code coverage. It'll conclude this book by showing you how to add coverage analysis to your CI build.

Enlarging on code coverage

Recall Chapter 2, Writing Well-structured Tests, and we know code coverage reports can be a useful tool to detect gaps of untested passages in our production classes. However, full coverage does not guarantee complete or even reasonable behavior verification. To substantiate these statements a bit more, let's take a look at a class highlighted with full coverage:

Full coverage

The preceding image shows the alleged pleasant case if full instruction and branch coverage has been reached. But it can't be stressed enough that full coverage alone testifies nothing about the quality of the underlying assertions!

The only reasonable conclusion to draw is that there are obviously no uncovered spots. In this sense, adding a single statement to a covered path...