1.Coverage
Coverage measures which lines of code actually ran during the test suite, as a percentage. It tells you what was NOT exercised at all — it does not tell you whether the lines that did run were tested correctly.
Key features
- pytest --cov=mymodule reports the percentage of its lines executed by the test suite
- --cov-report=term-missing shows exactly which line numbers were never run
- High coverage does not mean correct — a line can run without its result being asserted on
- 100% coverage is rarely useful — often means testing trivial code just to hit the number
- Coverage is most useful for finding UNTESTED code, not as a proxy for test quality
- 83% covered — line 7 never ran — a real, findable gap
- 100% covered, no assert — the line ran, but the result was never checked
- Chasing the number — testing trivial getters instead of real edge cases
Command
# pytest --cov=mymodule --cov-report=term-missing
#
# Name Stmts Miss Cover Missing
# ---------------------------------------------
# mymodule.py 6 1 83% 8Coverage shows which lines never ran — a floor for thoroughness, not proof of correctness.