A debugging hypothesis is a proposed explanation for a defect. Use it to turn a surprising test failure into a focused investigation: predict what is wrong, inspect the relevant state, and test whether the explanation holds. section 8.5
Build hypotheses from the failing behavior:
- Identify the edge case that exposes the failure. section 8.5
- Name a specific operation or value that may be wrong. section 8.5
- Set a breakpoint at that operation and inspect execution state. section 8.5
- If no useful hypothesis emerges, step through the function from its first line. section 8.5
A failing classroom-row test
A function reports three consecutive students when the expected result is four. Two hypotheses follow: updating count skips the final student, or updating max_count misses the final run. A breakpoint reveals that the final run is never compared with max_count; moving that comparison into the student branch fixes the result. section 8.5
