Coverage tells you which code ran during the tests. It does not tell you whether the tests check the right things.
There are four common types:
- Line coverage counts executed lines.
- Statement coverage counts executed statements.
- Branch coverage checks whether each outcome of every
if,switchcase and logical operator (&&,||) was taken. - Function coverage counts called functions.
What it is good at: finding untested code. A file at 0%, or an error branch that never ran, is a clear gap.
What it can't tell you:
- Whether the tests check results. A test that calls every function and asserts nothing still gives high coverage.
- Missing code. For example, a validation you never wrote can't show up as uncovered.
So 100% coverage can still miss bugs. Use coverage to find blind spots. Prefer branch coverage to line coverage. Don't treat the number as the goal.
- Coverage measures executed lines, statements, branches and functions.
- Coverage is good for finding untested code.
- Coverage says nothing about the quality of the assertions.
- Coverage can't show missing code, so 100% can still miss bugs.