Robert Smyth's Blog

Test Driven Development (TDD)

 

Test driven development (TDD) is a process for writing code.  It involves writing the tests first and then use the tests to guide what code is required.  When the tests pass, the coding is completed.  It can speed up development and help simplify the resulting code.  TDD used with code refactoring is a powerful way of writing code. 

 

As the tests are the requirements in code it is always possible to write the test first.  If not, then you do not know what your coding!  If a test is written prior to the code (one part of TDD) then:

  • The tests can be improved during development as requirements or possible faults are discovered during code writing.
  • The tests may be used to assist code writing (this is really TDD).
  • The tests are a record of "what is required".
  • Reduces the time from introducing a defect to detecting it.  This reduces development time and improves resulting code quality.
  • Tend to naturally lead to 100% code coverage.

There are no downsides to writing tests before writing the code, and there are definite potential benefits.  If sceptical of TDD, start by just writing your tests first.  After a short while you will find yourself naturally starting to use some TDD.

 

Links to TDD information:

Others of interest:

Interested in how to automate customer acceptance tests then checkout FIT.

 

Mail lists:

 

 

 

 

SourceForge.net Logo

 

Last updated April 2005, Email: robsmyth at bigpond.net.au