John Mason Presents On Unit Testing with CFCUnit

Posted November 14, 2007 at 8:37 AM by Ben Nadel

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.



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 »
10,640 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 »
9 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 A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
InVision App - Prototyping Made Beautiful With Prototyping Tools Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
Feb 10, 2012 at 7:21 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
Update! Instead of $(eval(options.insertAfter)).after(data['insertData']); I now use: var ajaxNode = document.createElement('span'); var parent = $(eval(options.insertAfter))[0].parentNode; ... read »
Feb 10, 2012 at 6:18 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
encountered this same, what I consider, jQuery bug last week. I'm building a site in which I load some content via AJAX. This content contains Linkedin share button placeholders which Linkedin API ne ... read »
Feb 10, 2012 at 11:30 AM
Cross-Origin Resource Sharing (CORS) AJAX Requests Between jQuery And Node.js
After you understand the concepts here, this is an awesome cheatsheet for enabling CORS in just about anything http://enable-cors.org/ ... read »
JM
Feb 10, 2012 at 9:10 AM
My Safari Browser SQLite Database Hello World Example
@Amy, Here is a very good tutorial on how to use JOIN: http://www.sqltutorial.org/sqljoin-innerjoin.aspx ... read »
Feb 10, 2012 at 4:42 AM
Building A Twitter-Inspired RESTful API Architecture In ColdFusion
This is great, very useful Ben. I spotted a small typo in the api.cgm listing: <cfthrow type="Unauthroized" /> Cheers Stefan ... read »
Feb 9, 2012 at 10:35 PM
CFDirectory Filtering Uses Pipe Character For Multiple Filters (Thanks Steve Withington)
I was wondering if there would be a filter you could apply so that you got everything but what you included in the filter. As in show me all docs that are not a .pdf. ... read »
Feb 9, 2012 at 10:29 PM
Learning ColdFusion 9: Application-Specific Data Sources
@Ben, No offence, but if people were really wanting advanced features they would be using a platform like ASP.NET MVC. CFML is so structurally compromised as a tag-based scripting language that ... read »
Feb 9, 2012 at 10:03 PM
Subversion - Cleanup Failed To Process The Following Paths
@Leviaguirre, do you still have problems with this? ... read »