🧪Test Coverage
Also known as Code Coverage, Coverage Report, Line Coverage
How much of your code your tests really run, as a percent.
Think of it like
Think of it like a map of a house that shows which rooms you have checked.
Example
Jack's report says cart.py has 50% coverage. The discount function never runs in any test, so he writes one for it.
Why it matters
It points at code no test has ever touched, which is where untested bugs wait.
Definition
Example code
console
$ pytest --cov=cart
Name Stmts Miss Cover
cart.py 6 3 50%Common mistake
Key takeaways
- 1A percentage. Of lines the tests ran.
- 2Shows the gaps. Lines no test touched.
- 3Ran is not checked. A high number can mislead.