Unit Testing is vital

Dear all

I just witnessed first hand the power of Unit Testing again… so wanted to share with you all… also as it is all so fresh in my mind ;-)
We were refactoring a large class… the intent was to take the guts out and replace it with STL containers and STL algorithms…

It took us two days to come up with 20 test cases that covered  the code well…. And the third day, as we started changing the code, the tests guided us on our way… pointing out where we went wrong ;-)

The next day we used the refacotored class into a non-trivial production code… and presto, it just worked, and performed well and so easy to maintain etc… 900 lines down to 178 lines ;-)

It took a lot of thinking to cover all corner cases with tests but once it was in place, its power is amazing ;-)

Adding a unit test also teaches you how/why some code really works — and they catch the ripple effect — I would say this is the biggest benefit ….
So people roll up your sleeves and write a test or two, and write them often… it would contribute greatly to the overall quality and rest the nagging doubt ( by making this change have I broken something? )

Writing Unit Tests is, I would say, an invlauable skill evey developer should learn about…. It is as vital as using a powerful editor…

Yesterday I went back and polished my Packet test cases and discovered some new tests ;-) And I felt so good after discovering them…

Let me know what you all think…
— Cheerio atul

Would you like to post a relpy?


This post starts a thread.
Follow-ups:
Re: Unit Testing is vital
Hello, Yes i afree that Unit test is useful. And test driven development(write first test and then code) helps a lot in some cases.  But i am wondering if unit test (more...)
Re: Unit Testing is vital
Hi Atul, Thanks for sharing your unit tests experience with us! I think each of us will learn lots of new stuff if more people share interesting experiences like this! I’m quite (more...)