Rubber ducking is a debugging technique: explain each line of code and its intended behavior in plain English to a real or imaginary helper. This makes hidden assumptions visible and encourages skepticism about every line, even simple ones. section 36.3
Use rubber ducking while tracing a failing test:
- Start with the inputs that caused the failure. section 36.3
- Pretend you are the computer and execute the program one line at a time. section 36.3
- Write down each variable value and ask whether it matches your expectation. section 36.3
- Explain what every line is trying to accomplish without programming jargon. section 36.3
A failing test
For a failed test such as test_abs_0, trace the call to funcs.absolute_value(0), state the expected value after each line, and question any unexpected result. A debugger may display variable values, but you still determine why the value is wrong. section 36.3
