Test the Calculation, Not Just the Output
Copying current program output into an expected result can preserve a bug. An invariant is a property that must hold, such as the stated initial temperature. Test hand-solvable examples and boundaries independently of the implementation.
Authored explanation · fixed examples, not a live experiment.
Choose hand-solvable cases
→Test initial conditions and split boundaries
→Inject a fault and observe the intended failure
Would your test catch a plausible bug?
By the end of this lesson
Use independent arithmetic and invariants to detect meaningful faults.
Inside the lesson
- Understand: Test the Calculation, Not Just the Output
- Make a prediction
- Work on the task
- Explain your decision
- Try a different situation
- Review and continue
The reproducibility tasks require running the supplied Python starter. Setup instructions and examples are included.