My experiences with test driven development

19 03 2009

Test-Driven Development (TDD) is a software development technique consisting of short iterations where new test cases covering the desired improvement or new functionality are written first, then the production code necessary to pass the tests is implemented, and finally the software is refactored to accommodate changes. The availability of tests before actual development ensures rapid feedback after any change. Practitioners emphasize that test-driven development is a method of designing software, not merely a method of testing.

I copied that definition from wikipedia. I am following TDD for the project that am working now. Not fully following, using for the core functionality. This is very new to me and I am feeling great to work on TDD. In the beginning I really struggled to write test cases. In fact my TL removed some test cases that I wrote in the beginning because they are not useful:( .

Am still in the learning stage only. Now I am writing test cases which are useful(I think 🙂 ).
These are the steps that I understand while doing TDD.

  1. Write test cases which fail. (because you didn’t write the functionality the test cases should fail.)
  2. Make the test cases to pass. (now write the functionality and make the test to pass.)
  3. Then do the re factoring on the function.
  4. Make the tests to pass.

I am more confident about my code now. Before that I am not having confidence about my code.
Before following TDD these are the problems I faced.

1. I am not sure about my code that it will work on all cases.
2. When I fix one bug , I am not sure that that bug fix will not cause failure to working functionality.
3. I don’t have confidence that this functionality works fine and it is not having bugs
4. I am unable to say any functionality is working fine.(I don’t have any functionality which is bug free). I don’t have any proof to say.
5. When am testing my application there is no proof that I tested every functionality, I used to forget testing many functionality.

After following TDD I am able to solve all the above problems. And am getting much satisfaction about my code because what ever small functionality I write I have confidence that it will work fine and it won’t break other functionality.

Some people may think that this method is very slow. It take time in the beginning to get into TDD but when you are trying to add more and more functionality it will be very easy to test and you can save the time of testing.

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: