Viewing By Entry / Main
July 15, 2008
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.

Comments

Added as a ticket! http://snipurl.com/2z730

I think it's getting to the point where I need to do a TQL based release!


@Mark, thanx!


I agree. We haven't implemented TDD as a part of our official workflow either (I've been working on introducing unit testing to our CFML and AS developers and getting them comfortable with how to write good tests firsts), but when I have done it myself, it has worked wonders for ensuring the quality of the code I release, as well and giving me a quick way to perform regression tests when implementing new methods in my CFCs.


Hello Sean,

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.


Let me second Shimju's comment. Wrestling with that very issue right now and advanced examples would really help.


Hi Shimju, It was a simple example, but you might want to check out the SCFUG connect presentation I did with Ben Nadel. It was mainyl about pairing, but we used a TDD approach and I certainly found that it helped me to "test infect" myself.

http://www.pbell.com/index.cfm/2008/4/29/Pair-Programming-with-Ben-for-SCFUG


Post Your Comments
Name:
Email Address:
Comments
*** Please note that all comments require moderation so it may be some time before your comment posts to this blog! ***
Remember My Information:
 



Hosting provided by