8. Essential Tests
TL;DR (5 lines)
- Read the core idea first.
- Understand one concept at a time.
- Run small examples.
- Fix errors early.
- Move to next chapter only when clear.
Frequent mistakes
- Skipping prerequisites.
- Reading without trying examples.
- Fixing too many errors at once.
Prerequisites: book/poche/07-reading-errors.html. See also: book/chapters/18-tests.html.
Goal
Write short tests that secure the basics.
Example
Nominal case + limiting case for each critical procedure.
Why it matters
Testing avoids regressions during refactors.
Quick check
What is the smallest useful test for add(a, b)?
Try this
- Add a nominal test.
- Add a limit test.
- Check the expected result.
If you're stuck
2 well-targeted tests are better than 20 redundant tests.
Mini quiz
- What is the main goal of this chapter?
- Which concept is most important?
- What will you try right now?
See also
Next best action
Apply one idea from this chapter in a tiny example, then continue.