What is Test Driven Development ?

refactoring-workflowAfter writing yesterday article on “Refactoring Workflow“, I am curious as to what really is Test Driven Development ? The objective is obvious, to deliver the perfect application with zero bugs.

Wikipedia do provides a good explanation for Test Driven Development :

“Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards.”

Source: Wikipedia

Test driven development involves three steps:

1. Create a test case.

2. Write code to pass the test.

3. Refactor the code.

The logic behind this is to create self testing code. This is done by first writing the test case. Then by writing the actual code to pass the test. Naturally, we want the test to be done automatic. There are tools that can help, which will be the topic for another article.

Now, once the code and the test are in sync. The code do pass the test, we then improve the code by refactoring. Some may call it optimizing the code.

Then repeat the three processes until the application is complete.

Test must be done regularly, everytime the code is updated. This is a key implementation.

With test driven development, developer are using bottom up method, where they start with the smallest feature of the application. Then start build the top layers.

Now, do keep in mind that this is one of the many methods available today. At least give it a try. I know I will.

Please share your experience with me in the comment section below.