Posted on

TDD: Let the Tests Drive

As long as we write tests, what’s the big deal about writing them “first” rather than “last?” Let’s explore that question.

The video looks a lot better on YouTube than it does here. Try https://youtu.be/Bf89rd0o5-0.

https://youtu.be/W1-IjCbzKAs

When we’re conscientious about writing examples before production code, and we drive all our production code from executable examples, we can enjoy several benefits:

  1. Helps us remember details and not overlook things
  2. Helps us avoid over-engineering or going too far with our design
  3. Helps us keep the design simple
  4. Provides a safety net for experimenting with different implementations
  5. Provides a safety net for refactoring
  6. Gives us frequent positive feedback so we don’t feel beaten down at the end of the day
  7. Provides executable low-level documentation of everything the application does
  8. Makes it easier to locate the source of bugs; keeps us out of the debugger for the most part
  9. Creates a regression test suite as a side-effect of writing the examples that drive the design
  10. Equally useful for emergent design and up-front design, and for greenfield development as well as enhancements and bug fixes