A unit test can really save you some time at the end of the end. I know what your thinking because I used to think the same thing. How on earth does writing more code help save time? Unless you write perfect code I am here to tell you it just will. I thought I would share a perfect example from a class I was writing this morning. I had a very simple method that took a string and repeated it x number of times. The class looked something like this. I had a simple unit test to make sure the repeat method was doing what it was supposed to.

My test kept failing over and over again and I could not figure out why. If you look closer you can see that I write to much ColdFusion code. I started my array loop at 0 and counted until the length of the string. This is going to throw and extra character in there. In Java this becomes much more of an issue because I have to compile my class and deploy it to my application. In ColdFusion I think its still a best practice to catch this now. This is because when you start writing code against your classes (or components) you can be confident that they will work.