Test-Driven Development

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:

  1. Write a test which specifies the desired behaviour
  2. 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)
  3. Write the code which makes the test pass
  4. Run the test; it should pass

See also