Why Unit Testing is so important?
Why writing unit tests are so important - lets consider a development team developing a module( call it - [A])did not consider the unit testing that seriously. What happens to that module -
1. [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 integration was failing again and again. So, the dependent module had to change as well to stabilize whole Delivery.
2. That's not the end of misery. In the release testing, huge amount of bugs identified which also produced from the uncertain behavior of [A] and fixing those become a hell of a job for the developers. Just to show you one old basic diagram of software development life cycle -
3. After the deliverable delivered to the client - Developers could not take pride for that because they were not confident whether they delivered a Good Product( from a developers perspective, I think its really crucial to deliver something from which you can take pride).
4. [A] became more susceptible and fragile day by day. And developers become really reluctant and was not comfortable to change the codes for any change request because of the code's inherent fragility.
5. Refactoring become very error-prone and troublesome.
So, after some time - Developers started calling [A] as "Dead Zone" or Legacy Code because [A] become quite impossible to manage.
Now if we go back to the days when the developers were planing or starting the development process using our Time Traveler- what would you advise them? :)
The situation that I just described, its not new to most of the developers developing for a long time. That's why some intelligent people in agile world sit together and come up with some basic rules and practices that we must follow to make our product worth taking pride. One of them is writing Unit Tests for your codes considering all the test criteria considering -
1. Unit Tests are the first users of your Unit who ensure that your own Creation is working that way you wanted to. Remember - "Taking pride". It become much easier to achieve.In addition, Learning Curve become much higher -because, you get to know very explicitly what are the cases you missed while writing unit tests initially that produce bugs. That way it makes you much mature developer day by day.
2. Unit Tests are the living description how the Unit should work. Any one new to your unit as a developer , should just need some time to go through the Unit Tests to get the Idea how the unit should work.
3. Unit Tests are the tools that make integration much easier.
4.Last but not that least - Refactoring was never been so much easier if there were Unit Tests.
Any comments or suggestions on this post is most welcome.