liveBook · Manning

Code coverage

As explained in Test Driven: Practical TDD and Acceptance TDD for Java Developers

Code coverage measures how much of a software system's code is exercised by its tests.

Code coverage measures how thoroughly automated tests exercise production code, including its source statements, branches, and expressions. Tracking it in builds helps reveal areas that receive less testing. section 1.5.4

Coverage measures can be useful when a team is starting unit testing or test-driven development. They show where tests reach, but a high number alone does not make a test suite effective. section 1.5.4 section 1.5

Why 100% is not always the goal

Going from 99% coverage to 100% may mean testing a condition that cannot happen. Choose a target with the technologies, languages, and tools in mind rather than pursuing perfect coverage blindly. section 1.5.4

How Test Driven: Practical TDD and Acceptance TDD for Java Developers covers it

How deep it goes
Defines coverage across statements, branches, and expressions, then discusses build use and misuse without detailing measurement tools.
Examples
Uses a 99%-to-100% target to show how perfect coverage can require testing conditions that cannot happen.
What you can do after
Evaluate how thoroughly tests exercise production code and identify less-tested areas without treating perfect coverage as the goal.
How it connects
Connects coverage with automated testing, unit testing, test-driven development, and continuous integration.

Also explained in

Compare how 15 books explain code coverage →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Test Driven: Practical TDD and Acceptance TDD for Java Developers. The section links point to the parts of the book it draws on.