Part I: The Money Example

In Part I, we will develop typical model code driven completely by tests (except when we slip, purely for educational purposes). My goal is for you to see the rhythm of Test-Driven Development (TDD), which can be summed up as follows.

  1. Quickly add a test.

  2. Run all tests and see the new one fail.

  3. Make a little change.

  4. Run all tests and see them all succeed.

  5. Refactor to remove duplication.

The surprises are likely to include

  • How each test can cover a small increment of functionality

  • How small and ugly the changes can be to make the new tests run

  • How often the tests are run

  • How many teensy-weensy steps make up the refactorings

Get Test Driven Development: By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.