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:
Specify the APIs to be called by tests
Write & Implement New Tests
Mostly, everything must fail. (Since no implementation is present)
Add new implementation for the APIs defined in
Make new tests pass. And ensure old tests do not fail. And thus, we keep adding new features without breaking old features.
Step 1if 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!