Test-Driven Development
A very popular technique to approach programming is Test-Driven Development or TDD. TDD consists of putting tests at the center of the developing experience.
This builds on some of the ideas that we exposed earlier in the chapter, though working on them with a more consistent view.
The TDD flow to develop software works as follows:
- New functionality is decided on to be added to the code.
- A new test is written to define the new functionality. Note that this is done before the code.
- The test suite is run to show that it's failing.
- The new functionality is then added to the main code, focusing on simplicity. Only the required feature, without extra details, should be added.
- The test suite is run to show that the new test is working. This may need to be done several times until the code is ready.
- The new functionality is ready! Now the code can be refactored to improve it, avoiding duplication, rearranging elements...