Test Driven Development is a way to develop software by starting the process by collecting a requirement, developing test cases for the requirement, followed by the coding process. On the other hand, traditional approaches perform testing after the coding is completed.
While TDD is well suited for developing complex projects with minimum defects, it may not be necessary for small projects.
How does it Work?
For TDD to work, we will have to use automated testing tools. Test cases are created using an automated testing tool and then write the code that causes the automated test(s) to pass. The steps are:
1. Collect and fully understand the requirements
2. Create automated test(s) that test the requirement
3. Create the coding logic - test teh functinality by running the automated test(s)
4. Once the automated test(s) pass, then the logic is implemented to fulfills the requirement[*]
5. Re-factor the code for better maintainability, run the automated test(s) again to ensure it still works
Advantages of TDD
Studies have shown that Test Driven Development reduces defect density, improves software quality, and in some cases make team productivity higher.