Canon TDD; make good interface decisions.

Why do it?

It’s in the writing of this test that you’ll begin making design decisions, but they are primarily interface decisions. Some implementation decisions may leak through, but you’ll get better at avoiding this over time.

This hits the reason why I value tests the most (as well as regression protection).

When I write tests I challenge my thinking and also get better interfaces and decomposition.

This is all from the man himself, Kent Beck; Canon TDD on Kent’s Tidy First Blog.

The process:

  1. Write a list of the test scenarios you want to cover

  2. Turn exactly one item on the list into an actual, concrete, runnable test

  3. Change the code to make the test (& all previous tests) pass (adding items to the list as you discover them)

  4. Optionally refactor to improve the implementation design

  5. Until the list is empty, go back to #2

Pro tip: use an ADR or a simple markdown file to document decisions, give context as to why that decision was made.