What is test coverage?

Definition

A coverage tool records which lines, branches or functions execute during a test run. The report can show which parts of a codebase still lack tests that reach them.

A high coverage percentage does not show whether tests check the right outcomes. A test can execute a branch without detecting an incorrect result, so review the assertions as well.

ELI5

Test coverage shows how much of a program the checks actually try out.

Imagine checking the lights in a house. If you try only the downstairs switches, the upstairs lights are still untested.

Does full coverage prove a program works?

No. A test may run code without checking the right result, and a coverage tool cannot account for every possible input.

Which kinds of coverage can you measure?

Common reports count executed lines, functions or branches. Each describes a different part of the code that the tests exercised.

  1. Kush Agrawal beside the words Agents Write Tests.
Definition card for test coverage: What is test coverage?

Test coverage measures how much of a program is exercised when its tests run.