Unit Testing is good for you
July 15, 2008 · 6 Comments
I'm working with Ray on some new features of the Broadchoice Web Platform and I'm building out some decorator methods to provide additional navigation across the object graph (essentially reverse navigation across many-to-many relationships).
I'm a big fan of unit testing but for a variety of reasons, we haven't quite established TDD as a day-to-day part of our operations at Broadchoice (something I want to change and as we bring on new team members this summer, we will instigate this as "Standard Operating Procedure").
However, today I wrote my unit tests first because I wasn't quite sure of my TQL syntax and figured that writing the tests first would help me navigate to the correct code.
It worked! Not only did I (re-)learn the lesson that TQL does not allow select class.* ... (Why Mark? It allows select * .... Can't it figure out all properties of a specified class? I know, enter it as an enhancement in the Transfer bug tracker!), but I also uncovered a bug in my transfer.xml file and a few other typos in pieces I'd mistakenly written before I started on these two decorators and their tests.
So, there you have it: write unit tests! Write them before you write your code! It helps you avoid committing code that won't run and that means less pain for your team members.
Tags: coldfusion · tdd

6 responses so far ↓
1 Mark Mandel // Jul 15, 2008 at 3:10 PM
http://snipurl.com/2z730
I think it's getting to the point where I need to do a TQL based release!
2 Sean Corfield // Jul 15, 2008 at 3:39 PM
3 Ryan McIlmoyl // Jul 15, 2008 at 6:50 PM
4 Shimju // Jul 15, 2008 at 10:01 PM
Lot of developers like me still not clear about Unit Testing's Importance. In every example of Unit Testing Framework we can see testing of simple methods like add(), subtract(), divide() etc... but that doesn't make any sense in real project development.
Can you please blog about how to effectively use MXUNIT illustrating a real example.
5 Rick Mason // Jul 16, 2008 at 4:26 AM
6 Peter Bell // Jul 16, 2008 at 8:06 AM
http://www.pbell.com/index.cfm/2008/4/29/Pair-Programming-with-Ben-for-SCFUG
Leave a Comment