Test-driven development (TDD) makes validation part of coding rather than a final check. Divide software into small units, anticipate edge cases, write tests for likely failures, and make the implementation pass them. Some developers write each test before its code. The useful target is reliable software—not an impressive pile of unlikely tests. section 5.6
A practical TDD loop looks like this:
- Split the code into small units of behavior. section 5.6
- Think through edge cases and things that could go wrong. section 5.6
- Write an individual test for each important failure or expected behavior. section 5.6
- Implement or adjust the code until it passes. section 5.6
- Keep the test when it replaces an ad hoc check, but avoid spending excessive time on extremely unlikely scenarios. section 5.6
Replace the temporary check
When tempted to run software and inspect a print statement, write a test case for that behavior instead. The test remains in the codebase and can catch regressions later. section 5.6














