Test coverage percentages and code ratios prove nothing
David Heinemeier Hansson dismantles the industry habit of quoting 90% test coverage or a three-lines-of-test-per-line-of-code ratio. Applied mechanically, these numbers are identical for trivial code and for code that could cost thousands of dollars or hurt someone. The metric measures volume of testing rather than whether the risky parts are protected.
- Coverage percentage is indifferent to what the code does
- Fixed test-to-code ratios ignore context entirely
- The same number can represent both waste and negligence
- What matters is whether the software is fault-free, not how many tests exist
“We write three lines of test code for every one line of production code. That’s a ratio I’ve heard stated in the path, and I…”