Wednesday, December 6, 2006

Why do we avoid writing unit tests most of the time?

In our early computer science classes we are taught about the formal software development methods. One the most important part of software process is "Testing". Testing comes in various stage of a software product. Some occurs in development phase like unit testing others like regression testing, takes place when a software is under the hands of QA team. One thing that most of the developer don't like is to write unit tests (That also includes me). We all the know the benefit of test based software development but i can assure you most of the time we try to avoid this up. This is not only true for ISV's but also companies like Microsoft. For example, the first release of Microsoft Word(http://www.joelonsoftware.com/articles/fog0000000043.html - check #5 Point). In all the cases when there is a bug in live system , it surely proves that proper testing process has not been executed. This true for all of us. Now why we avoid testing at early stage, well let's look into the following

1. In tight schedule program, often the unit test is almost skipped.This is beacuse , our client are in a real hurry to get a running version. This happens in most of the outsourced projects where budget is a big factor.
2. Programmers are too lazy to write unit tests[ example. me :-)].
3. Time Saving.
4. 100% Confident about a piece of code.

Now as we have so many excuses to avoid writing unit tests, i would like to add one more controversy to it. Let's say a developer has wrote a magnificent piece of complex javascript code that is the heart of software system, after a year or two the developer leaves the company , and right after a major update the code somehow breaks. Now what will happen, think ? If there was unit test for this, don't you think it could have been much easier to point out the exact error?

Au revoir!

1 comment:

msarker said...

Well I think from developers point f view your points are wright.And as u write at last, I admit that unit testing is necessary for the future maintenance. I think u guys still should try to develop the unit testing code for a better bug free product, though it time consuming.But it really ensures quality.