2.6. TDD — Practice

In practice, TDD is more than what meets the eye.


One Extra Step is needed: Specify the APIs to be called by tests.

So, in Practice it is:

  1. Specify the APIs to be called by tests

  2. Write & Implement New Tests

  3. Mostly, everything must fail. (Since no implementation is present)

  4. Add new implementation for the APIs defined in Step 1

  5. Make new tests pass. And ensure old tests do not fail. And thus, we keep adding new features without breaking old features.

  6. Repeat from Step 2 (or Step 1 if needed)…

The 1st step Specify the APIs to be called by tests, is sometimes not as easy as it seems.

  • We have to specify a good name of the API

  • The parameters of the API

  • Pre-conditions of calling that API (i.e. specify more APIs)

  • Many Enumerations / data types / data structures that need to be part of such APIs, etc.

  • All these steps may take longer than expected.

  • Any change in APIs would have a cascading effect. But, this is bound to happen because development has not started yet.

  • If you do not have access to good refactoring tools in your programming language/environment, good luck!