Code Coverage
Explore the concept of code coverage in unit testing Java applications. Understand how tools like Emma and Cobertura measure code and branch coverage, and learn why coverage numbers should guide educational insights rather than managerial pressure.
We'll cover the following...
Managers love numbers. The concept of code coverage, a term for how much code is unit-tested, is one that tickles the typical manager’s number fixation but ultimately leaves a bad taste when used for anything but educational purposes.
Code coverage
More specifically, code coverage is a measure of the percentage of code that our unit tests execute. We can find tools that do the dirty work of taking the measurements. Emma (which we show briefly here—it’s a free and easily installed Eclipse plugin) and Cobertura are examples of code-coverage tools.