# Test Coverage

> How much of your code your tests really run, as a percent.

**Field:** Software Development  
**Category:** Testing & Quality  
**Also known as:** Code Coverage, Coverage Report, Line Coverage

## Think of it like

Think of it like a map of a house that shows which rooms you have checked.

## Definition

Test coverage is how much of your code runs when the tests run. It is shown as a percentage. A tool watches the tests and marks each line that was reached. A report then lists the lines no test touched. Many teams aim for around 80%. But coverage only says a line ran, not that a test checked its result.

## Example

Jack's report says cart.py has 50% coverage. The discount function never runs in any test, so he writes one for it.

## Example code

```console
$ pytest --cov=cart
Name      Stmts   Miss  Cover
cart.py       6      3    50%
```

Half the lines in cart.py never ran during the tests.

## Why it matters

It points at code no test has ever touched, which is where untested bugs wait.

## Common mistake

Chasing 100% coverage. Tests written just to raise the number often check nothing.

## Three principles

- **A percentage.** Of lines the tests ran.
- **Shows the gaps.** Lines no test touched.
- **Ran is not checked.** A high number can mislead.

## Related terms

- [Test Suite](https://learn.benibix.com/term/development/test-suite)
- [Unit Test](https://learn.benibix.com/term/development/unit-test)
- [Test-Driven Development (TDD)](https://learn.benibix.com/term/development/test-driven-development)
- [Assertion](https://learn.benibix.com/term/development/assertion)
- [White-Box Testing](https://learn.benibix.com/term/development/white-box-testing)

---

Source: https://learn.benibix.com/term/development/test-coverage
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
