Why is Unit Testing so important?

Why should we write unit tests? Why is it so important? To realize that we consider a team that is developing a module (say, module A), however, did not consider unit testing that seriously.

What does happen to that module?

1Module A produced lot of bugs in the development phase since it was not tested adequately. And while fixing it– A produced severe impact on other modules too, because of the fact that integration was failing again and again. Hence, the dependent modules had to change as well to stabilize final delivery.

2That’s not the end of misery. In the release testing, huge amount of bugs are identified, which resulted from the uncertain behavior of A, and fixing those become a hell of a job for developers. Just to show you one old classic diagram of software development life cycle–


3After relevant modules are delivered, developers could not take pride for that because of the lack of confidence regarding whether they have  delivered a quality product (from a developers perspective, we think that it is  really imperative to deliver something from which we can take pride). Please refer to the done concept of agile development to get more idea on the quality of product that we are referring. 

4 Through the course of time, A would become more susceptible to changes. And developers would become really reluctant and not comfortable to change the codes for any change request. More so, refactoring would become error-prone and troublesome due to the lack of unit and integration tests.

So, after some time, developers would start referring A as “Dead Zone” or Legacy Code, due to difficulties in its maintainability.

Now if we go back to the days when the developers were planning or starting the development process, what would you advise them ?

The situation that we have just described,  its not new to most of the developers developing for a long time. That’s why some intelligent people in agile world sat together and came up with some basic rules and practices that we must follow to make software product more maintainable. One of core principle  is to performing unit testing considering all the test criteria.

1Unit and integration testing verifies semantically correctness of software modules and how they should interact with each other. In addition, impact of changes can be easily determined, and be thoroughly tested if unit testing is done properly. In addition, it becomes easier to do code refactoring, module integration and most importantly, allows quick bug detection. To sum up, according to our experience, unit testing   improves the maintainability of software to a great extent.

2Consider unit tests as the specification of modules or software.  Any developer new to software module could just go through the unit tests to get an overview of what that module semantically entails. Thus, not only units test improves maintainability, it also enhances understanding of complex software systems.

Any comment or suggestion regarding this post is highly appreciated. Thanks!

See More


[R-1: 02-04-2013] Porting blog-post from the following URL: http://weblogs.asp.net/adilakhter/archive/2008/04/18/why-unit-testing-is-so-important.aspx .


2 thoughts on “Why is Unit Testing so important?”

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: