Test Driven Development (TDD)

Test driven development is an advanced technique that uses unit tests to drive the design of software. It is a technique for building software that guides software development by writing tests. This article explain an introduction to Test-driven Development. Summary of the article:

  • What is Test Driven Development (TDD)?
  • History of TDD
  • TDD Life Cycle
  • Why TDD?
  • Tools for TDD

What is Test Driven Development (TDD)?
Test Driven Development or Test Driven Design or TDD is a software development process where the main concept is “get something working now and perfect/accurate it later”. Here unit testing is repeatedly done on source code. After one test, refactoring is done and the same test is performed again. The process is repeated as many times as necessary until that unit is functioning according to the desired specifications.

In TDD the developer writes a test before writing final codes to fulfill that test and refactors the code to pass that test. In a traditional non-TDD technique, developer writes code to implement functionality. After finishing, test the codes, if any error found modify the codes and finally test it again. A sample diagram that represents the entire cycles is given bellow:

Test Driven Development (TDD)

But in TDD, at first the developer writes test rather than final production code. After that, check the test, if fail made some modifications. Same process is repeated until the final destination is obtained. A sample diagram for the entire process is given bellow:Test Driven Development (TDD)

TDD is not all about testing. It is about development (and design). It is specifically for improving the quality and design of code. Here the resulting unit tests are just an extremely useful by-product. TDD is a process that relies on the repetition of very short development cycle. It is based on the test-first development concept of Extreme Programming (XP) which encourages simple design with high level of confidence.

History of TDD
The TDD was introduced by Kent Beck. TDD is a part of larger software design paradigm which is commonly known as Extreme Programming (XP).

TDD Life Cycle
In order to start works with TDD it is very important to understand its life cycle. The life cycle of TDD is given bellow:

  • Write the test
  • Run the test (there is no implementation code, and test does not pass)
  • Write the implementation code to make the test pass
  • Run all tests (tests pass)
  • Refactor

Why TDD?
Someone may ask why we should use TDD; my development is going perfectly without TDD. Remember that, no techniques/process is the best for all cases. Actually TDD provides lot of benefits over traditional non-TDD techniques. Some advantages of TDD are given bellow:

  • Today systems are becoming bigger and complex. So automated testing is prefarable.TDD provides automated testing which is easier and faster than manual testing. Automated testing requires less manpower than manual testing which reduce cost. There is no chance to miss any things in automated testing
  • TDD is good for any new features or modifications of existing features. In manual testing we need to test all the features which may be affected by the new/modified features. But in automated testing this process is not required
  • TDD offers quicker delivery of the system. Because, its needs to engage less QA persons for checking
  • TDD is a better option for bug fixing

Tools for TDD
There are many testing frameworks and tools are available for TDD. Some of them are given bellow:

  • xUnit Framework
    xUnit.net is a free, open source unit testing tool for the .NET Framework.
  • csUnit
    It is a free and open source unit testing tool for the .NET Framework.
  • HTMLUnit
  • VBUnit
  • PHPUnit
  • TAP results
  • .Net Framework
    Microsoft introduced TDD with Visual Studio 2012.

Some people may argue that TDD is time consuming than non-TDD approach. This is true for new comer during introducing or learning stage, those who are not expertise in TDD. But after practicing when someone is familiar with TDD this idea will be wrong. Then he/she will enjoy the real benefits of TDD approach.

Leave a Reply

Your email address will not be published. Required fields are marked *