liveBook · Manning

Code coverage

As explained in The Art of Code

Test coverage is a measure of how much software code or behavior is exercised by automated tests.

Code coverage measures which important paths automated tests exercise. Meaningful coverage includes core business logic, edge cases, invalid inputs, and expected failures—not merely a high percentage. section 9.3

Use coverage to check whether tests address:

  • Normal success behavior and core business logic. section 9.3
  • Edge cases and invalid input. section 9.3
  • Expected failures, including security-related cases. section 9.3
  • Gaps that require judgment rather than automatic pursuit of a metric. section 9.3

Cover both branches

A pounds-to-kilos converter needs tests for a valid value, zero, and a negative value that throws an exception. Together, these tests exercise conversion, a boundary case, and the failure path. section 9.3

How The Art of Code covers it

How deep it goes
Frames meaningful coverage through success, edge, and failure paths but does not detail coverage-measurement internals.
Examples
Uses a weight converter with valid, zero, and negative-input unit tests.
What it assumes
Assumes familiarity with automated tests and code paths while emphasizing expressive, low-complexity test design.
What you can do after
Evaluate whether a test suite covers important behavior and expected failures without chasing metrics blindly.
How it connects
Connects coverage with automated tests, unit tests, business logic, edge cases, and failure scenarios.

Also explained in

Compare how 14 books explain code coverage →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.