John Mason Presents On Unit Testing with CFCUnit

Posted November 14, 2007 at 8:37 AM

Tags: ColdFusion

Last night, John Mason came up to the New York ColdFusion User Group to present on unit testing in the CFCUnit framework. First, I just wanted to send out a big thanks to him for coming all the way up from Atlanta to share his expertise with us. His presentation was quite good and is available on labs.fusionlink.com. While I have not had a chance to look at the resources he has posted online, apparently it contains quite in-depth coverage on setting up the CFCUnit framework and how to leverage it and ANT-automate it effectively within CFEclipse.


 
 
 

 
John Mason of Fusion Link  
 
 
 

Unit testing is something that is particularly interesting to me because I am now at a point where I'm actively learning more about object oriented programming and the use of it within ColdFusion. I have watched presentations on unit testing before, but sadly enough, it was only recently that I realized that CFCUnit (and unit testing in general) is really only geared towards ColdFusion components. Apparently, there are ways to unit test individual CFM templates, but where CFCUnit really excels is in its ability to exhaustively test the methods of a given CFC. I think this point is often glossed over because it is assumed that people who are interested in unit testing already understand what a "unit" is.

Anyway, the idea writing test cases as you write your components is a bit paradigm shift for me. While I do a great deal of my testing during development - I'm very much a "code a bit, test a bit" programmer - all of my testing is lightly structured and manual. This method works decently on small sized projects, but for larger projects, I can really see how automated testing saves you in the long run when it comes to regression testing and general maintenance of software.

In addition to unit testing CFCs, John briefly covered user interface testing with Selenium. During the presentation, I was not exactly sure if Selenium was plugging into the CFCUnit framework, or whether its use was just being automated through CFEclipse and ANT. Either way, it was nice to see that someone does automated UI testing, if for no other reason than to prove to me that Selenium is worth looking into. I tried using it one time on an existing application and found it totally overwhelming. But, seeing him use it, I am convinced it's worth another look.

About The Speaker

John Mason works at FusionLink, a ColdFusion and Flex hosting company based in Atlanta, Georgia. He has been programming with ColdFusion since 1996 and Flash since 2001. John was a contributor to the CFDJ and actively posts on several ColdFusion, Flash and Flex related lists. He holds an Adobe ColdFusion Advance Certification and also MBA from Georgia Southern University. Currently, he enjoys working on his Flex certification and building beta applications in AIR.

Post Comment  |  Ask Ben  |  Permalink  |  Print Page




Reader Comments

Nov 14, 2007 at 6:33 PM // reply »
1 Comments

Thanks for the review! I had a great time presenting to NYCFUG and meeting you guys. Thanks again for inviting me.

Just a couple of comments I want to add for those that run across this information. CFUnit (not to be confused with cfcUnit) has an assertion test for CF templates like to the standard *.cfm or *.cfml pages. I have not had much luck with it, but it is there if you need it. But like Ben says in this posting, these unit testing frameworks really are design for testing units (classes) and their methods which in the CF world would normally be a Coldfusion component (*.cfc page).

The Selenium stuff I showed at the end wasn't directly plugged into cfcUnit. I simply automated it's testing as well inside of my ANT scripts the same way as I would the cfcUnit tests. If you have an older site that isn't using many CFCs, the Selenium tests can still be very useful in testing your application.


Nov 15, 2007 at 7:05 AM // reply »
6,371 Comments

@John,

All of the ANT stuff looked very cool. I am still rocking old school HomeSite 5.5 so none of that stuff comes with it. I think it's time that I make yet another attempt to switch over to the Eclipse editor.


Nov 26, 2007 at 6:00 PM // reply »
6 Comments

Checkout out http://www.thecrumb.com/wiki/Selenium for selenium stuff and my post about running selenium within ant http://tinyurl.com/2k47wt


Feb 22, 2008 at 3:54 PM // reply »
31 Comments

I've really relied on CFUnit for my current project, I found it did two things for me:

1. It moved me in to test driven development, and forced me really think what I wanted each component to do, and to limit the complexity of, dependencies between my components, so I could have 'testable' code, and could test each component is isolation.

2. As I built up my test suite, my development time began to speed up considerably, because I could quickly test all my components to see the impact of a change, and if something 'broke', I 'knew' that previously tested components worked, so the problem was in the new/changed component.


Post Comment  |  Ask Ben

Recent Blog Comments
Nov 7, 2009 at 5:53 PM
Ask Ben: Javascript String Replace Method
You can find here an advanced function that prepared with javascript replace function. This can make the first letters of words, sentences, lines and whatever you define automatically: http://www.m ... read »
Andrew Neely
Nov 7, 2009 at 4:56 PM
A Moment That Touched Me - The Fountainhead
Ben, Glad you enjoyed the podcast. Yeah, the Tank Riot guys can get really chatty during the episodes, but that's part of the charm of it for me. They've covered everything from Nichola Tesla to Cha ... read »
Nov 7, 2009 at 4:43 PM
Building A Fixed-Position Bottom Menu Bar (ala FaceBook)
Is it possible to make some more MenĂ¼`s ? ... read »
Jill
Nov 7, 2009 at 11:40 AM
How To Unformat Your Code (Like A Pro)
Derek, I think you might be right - sweet! Thanks for the link :) ... read »
Nov 7, 2009 at 11:25 AM
How To Unformat Your Code (Like A Pro)
I think it would be way easier to just use this http://www.logichammer.com/html-formatter/ He just released v3 and it rocks. ... read »
Jill
Nov 7, 2009 at 7:58 AM
How To Unformat Your Code (Like A Pro)
LMAO - this was pretty funny! I have to admit - I also love to reformat code so I can read it. My boss used to tell me to leave my OCD at home. Now I don't feel so bad after reading everyone else' ... read »
Nov 6, 2009 at 10:10 PM
How To Unformat Your Code (Like A Pro)
The timing of this post is just uncanny. I spent the last 15-20 minutes manually un-formatting my "Ben Nadel" style code within a CFC of mine. I was really digging the readability a few weeks ago, bu ... read »
Roe
Nov 6, 2009 at 5:11 PM
Passing Arrays By Reference In ColdFusion - SWEEET!
ArraySort also reorders the results of these java obj's ... read »