Notes on TDD as if you meant it

16 Dec 2019

Notes based on TDD as if you meant it by Keith Braithwaite.

The games Go and Tic Tac Toe are good candidates for practicing TDD as if you meant it.

Keith Braithwaites Rules

  1. Write exactly one new test, the smallest test you can that seems to point in the direction of a solution.
  2. See it fail.
  3. Make the test from (1) pass by writing the least implementation code you can in the test method..
  4. Refactor to remove duplication, and otherwise as required to improve the design.

Refactoring rules

If you want a new method, wait until refactoring time, then create new non-test methods by:

  1. Preferred: Do Extract Method on implementation code created as per (3) to create a new method in the test class, or
  2. If you must: Move implementation code as per (3) into an existing method.

If you want a new class- wait until refactoring time, then create non-test classes to provide a destination for a Move Method and for no other reason.

  1. Populate implementation classes with methods by doing Move Method, and no other way.

After some time coding: