What is TDD?
The shortest possible description of TDD is actually the term itself. It describes that, by using this as your methodology for your application development, this development will be driven by tests. Meaning, tests need to be defined to trigger the writing of your application code, and in this, your tests are directly derived from the requirements. The ultimate consequence of this is:
You will never build code that does not have tests to it, and, as the tests are one-to-one related to the requirements, your application code will not have any undocumented features.
Only two rules to the game
The preceding description is not the basic definition of TDD. TDD is defined by only two rules, and everything else is deduced from that:
- Rule 1: Never write a single line of code unless you have a failing automated test.
- Rule 2: Eliminate duplication.
The first rule clearly defines the trigger for writing application code...