Chapter 5 of 10All chapters
Chapter 5 of 10
Coverage and flakiness
Two numbers that mislead.
Coverage
Coverage measures which lines ran during tests. It is useful for finding untested areas and worthless as a target, because a test with no assertions covers everything and proves nothing.
- Chasing a percentage produces tests written to touch lines.
- Look at what is uncovered rather than at the number.
Flaky tests
A test that fails intermittently is worse than no test, because it teaches everyone to rerun the build. Fix it or delete it; leaving it is a choice to ignore failures.