Posted by Sébastien Lachance with Comments (0)
To be honest, I believe that we have reached a point where we can’t allow ourselves to deliver untested software. I lived through a lot of maintenance work and debugging that were so time consuming that It took more time to debug than it took to actually develop. And it’s for that reason that I believe that unit tests are essentials and should belong to every developer toolbox.
It’s actually not so hard to learn and a lot of resources already exists to get you started rapidly (Roy Osherove and his book are a must).
I also believe that unit tests have a strong positive impact to the design of the code. Doing correctly, TDD (test-driven-design or test-driven development) is a powerful tool. I’m talking with experience here and it’s very impressive. I worked on two almost identical project and one was driven by test and the other was not. The quality of the design was much much better on the project that was test driven than the other one. But what was way more impressive was the number of changes made to the structure of the project. Code with tests has evolved tremendously and untested code had a static structure that stayed the same over the course of it’s development.
And a great one it is. I recently had to create regular expression to find email in some large text file. Instead of rapidly hitting google for a rapid solution, I created a class library, added the nUnit framework and started writing tests. This way, I could test assumptions and learn some aspect of writing regular expressions. I learned a lot.
Today, I can’t believe myself when I see a method that contains logical code, and no tests. Tests are so easy to do (when you actually know how to do them) that it’s almost a shame to forget about them.
And here is my answer to the “we don’t do test because our organization don’t want to” argument : Don’t tell them. You are responsible for the quality of your code and it’s very unprofessional to leave code go in production that you knew would have been much better and feel more confident if it was tested. I believe the advantages outweigh the disadvantages in this particular case.
This is my point of view.
Related posts