Garren Smith

Unit Testing beginners feedback

. 9 Sep 2009 - Johannesburg

The company I work for does not practice automated unit testing or any other form of automated testing.Testing has always been the practice of manually testing. This is incredibly tedious, frustrating and way to much elbow grease for a lazy developer. Ofter reading about my 100th blog that said "If you not testing you are an Idiot", I decided to be brave and swim against the stream and start implementing unit testing. I bought Pragmatic Unit Testing in C# with NUnit, which is a great book and is gives an excellent introduction into Unit Testing. After reading a fair bit about Test Driven Development I decided while I was still finding my feet to following the wise words of Karl Seguin in his free ebook (definitely worth a read)
"I recommend that you familiarize yourself with unit testing in general before adopting TDD."
Tools of the Trade
Every good craftsman needs useful tools to be effective, I "tooled up" using Nunit, RhinoMocks and Gallio. These tools really helped the process and made my life a lot easier. Gallio is a fantastic test runner and more, Nunit and RhinoMocks should need no introduction. Now to the actual meat of this post, my actual experience. All I can say is it was like the rain had come after a dusty hot day and cleared the sky. Everything made sense and I was forced to write better code that was testable, maintable and easier to understand. Ok not straight away... Initially I found myself producing code at a slower rate , fighting off the critics at the office I perserved. I then started realising that the amount of time spent debugging was minimal. I was spending more time coding and less time entering data in textboxed on our forms, trying to replicate the bug and then hoping the debugger would break at the right spot so I can fix the error. Then repeating the manual test until it worked. About 2 months of unit testing I am finding that I am producing code at a better rate and feel more confident in the quality of it. I would like to investigate TDD more now as well as writing more effective tests . Unit testing definitely makes you more aware of the SOLID principles and I found that my code was a lot more decoupled - so that I can mock each object. I was also more aware of the law of Demeter and consciencly making sure that all my objects obeyed the Single Responsiblilty Principle. I definitley have lots to learn still and am still getting to grips with mocking. I can really say that the biggest acheivement in my short programming career has been to unit test!
blog comments powered by Disqus
Fork me on GitHub