Looking for "smelly" code through code coverage

This recipe uses Cobertura (http://cobertura.sourceforge.net/) to find the code that is not covered by unit tests.

With consistent practice, writing unit tests will become as difficult as writing debugging information to stdout. Most popular Java-specific IDE's have built-in support for running unit tests. Maven runs them as part of the test goal. If your code does not have regression tests, the code is more likely to break during refactoring. Measuring code coverage can be used to search for hotspots of non-tested code.

For more information, you can review http://onjava.com/onjava/2007/03/02/statement-branch-and-path-coverage-testing-in-java.html.

Getting ready

Install the Cobertura code coverage ...

Get Jenkins Continuous Integration Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.