Code without Tests, A journey to Chaos
It was a very busy week.
One of our Project had a release date planned and at the same time the
Web API team done some breaking changes. The application we were building is
huge and we didn’t had much time to analyze what could break because of those
changes. We in the team figured out couple of places which could get affected
by these breaking changes and we started to incorporate these changes in the
application. In a week our QA team had a test round on the part of the
application which got affected and gave us the green flag. It was Thursday,
There was a long weekend ahead of us, and we wrapped all the work at our end
and provided the application for the internal QA team of the client. After testing the application, the
internal Client QA team dropped a long mail at that night saying they are
rejecting the build as one of the module from the application is not working at
all. I was travelling to my home town for the long weekend, I received a call
from my manager to inform me that the application is rejected because we
missed one important module. All the developers in the team worked on the long
weekend to fix the broken module. While working in hurry, we introduced couple
new bugs while fixing the broken module. No one in the team wasn’t sure if they
have introduced some issues because of their fixes, and that is what happened.
We fix something in hurry, and that affects something else. Finally we were
able to close all the open issues and get the sign off the Client QA team.
In this all chaos I realized the importance of wring Unit tests. I had faced similar situations before, but in all those cases we always had giant safety net of tests. If you have unit tests to back you, you will always have the confidences that the changes in code will not break anything. The feedback cycle is quick, if you break anything you will know about it within seconds.
In this all chaos I realized the importance of wring Unit tests. I had faced similar situations before, but in all those cases we always had giant safety net of tests. If you have unit tests to back you, you will always have the confidences that the changes in code will not break anything. The feedback cycle is quick, if you break anything you will know about it within seconds.
Also one important benefit of having test is, it encourage
you to refactor the code. You might feel what the relation of tests and
refactoring the code is. There is a close relationship of Refactoring and unit
tests, let’s assume you are dealing with a huge codebase without any tests, and
you find out one of the core module of the code has badly written. You decide to refactor it, but then you
realize that there are plenty of manual testing efforts after refactoring the
code is required as there are no automated tests. If you still refactor the
code and put all the efforts of manually testing it, you won’t have that
confidence of everting will work as expected. Every code requires refactoring
at some point because it is impossible to write a perfect code at first
attempt. Having tests over the code boosts the confidence of developers,
Developers in the team will not hesitate to refactor the code if it is rotten.
The benefits of Unit tests will not be visible to you if you
haven’t gone through such situations. Humans are not good at handling complexity,
it should be done by computer in an automated way. We are good at finding
creative solutions to the problem. The manual regression testing efforts
required for huge application is big, and I think all that can be reduced by having
tests on the code.
Nice
ReplyDelete