Test-Driven Development or TDD is a development style in which programmers write tests prior to writing the code to be tested. Test-writing therefore drives development and serves as a guide as to what should be implemented next. The process of designing the software becomes intimately entwined with that of designing the tests.
The basic cycle is:
- Write a test which specifies the desired behaviour
- Run the test; it should fail (this is an important step to confirm that you haven't accidentally written a faulty test which passes even when the application doesn't work)
- Write the code which makes the test pass
- Run the test; it should pass