Proposes to write the tests before the production code.
TDD Cycle
Advantages of TDD
- By creating the test first, we also look at the requirements first
- We can control our pace of writing production
- The tests are derived from the requirements
- Testable code from the beginning
- Quick feedback on the code that we are writing
- Baby steps
- Feedback on design
Should we use TDD 100% of the time?
- You should use TDD if you don't know how to design and/or architect a part of the system.
- Or when you are dealing with a complex problem, in which you lack experience (the use of baby steps might help you to start slowly)
DON'T use TDD if you are familiar with the problem or the design decisions are clear in your mind. If there is nothing to "be learned or explored"
Exercises