tdd_cycleThere are probably a lot of misunderstandings about Test Driven Development (TDD) and a general unawareness about what it is so I am hoping you will gain a better understanding after reading this article.  I have a nice image on the left which will help to provide better information for TDD.  The general thought process is by creating an initial test case which is designed to fail, the developer will design better code which will make the test pass.

TDD Steps

  1. The TDD test created will be a simple unit test that will affect a very small piece of code.
  2. Once the unit test has been created it needs to execute and fail.
  3. The developer will then write code to get the test to pass.
  4. The developer will refactor code to make it simpler and more efficient.
  5. The developer will repeat the process and add more tests over a period of time.

 

TDD Benefits

  • There is a significant number of defects that are reduced provided this approach is used consistently
  • The additional effort spend with save significant time on the downstream teams since less time will be spent fixing and retesting defects
  • Code design improves

Common Mistakes

  • Forgetting to run the tests
  • writing too many tests
  • writing tests that are too detailed
  • writing tests that are not effective
  • only used by some of the developers on the team
  • tests are not maintained over a period of time
  • new team members don’t use previously created tests

I hope this article will help and provide you with better information on TDD.  If you would like more information on Agile, DevOps or Software Testing, please visit my Software Testing Blog.