Test Driven Development and ColdFusion - From the Mouth of a .NET Developer!

Dec 14, 2005
by Judith Dinowitz

Take one experienced .NET programmer who's familiar with the Test Driven Development methodology. Sit him down with ColdFusion for a few hours. Then have him prepare a presentation to a ColdFusion User Group on TDD with ColdFusion. Is this a good user group experience, or a recipe for disaster?

According to Jonathan Cogley, the .NET developer mentioned above, this was definitely a good experience, both for him and for the Maryland ColdFusion User Group. "I was asked by the president of our local ColdFusion user group, Michael Smith, if I would like to present at a meeting," Jonathan said. "Being an avid developer community supporter, I volunteered some topics and Michael picked Test Driven Development. I have presented on TDD and related topics on many occasions, but always to a .NET audience. This was now an exciting opportunity to pitch to different audience. I didn't think the presentation would have impact unless I could demonstrate the technique in the language of the group ... which meant learning ColdFusion. At least enough ColdFusion to be capable of demonstrating TDD in action."

Learning ColdFusion

Jonathan found ColdFusion MX 7.0.1 easy to install. "The install reminded me of installing Java application servers a few years back." Due to limited preparation time for the presentation, he couldn't delve into any IDEs. "This was actually a little disappointing since I have heard good things about the ColdFusion development tools. I did all of my development by working from the tutorials that came with the install and Notepad. I installed CFUnit (SourceForge project) as my ColdFusion unit testing framework and worked from the samples. I worked mainly with CFCs and built test fixtures to test their functionality."

Jonathan wrote this experience up in his blog, where he noted "the mind shift that had to occur for my brain to begin processing in a tag-based environment." As a programmer experienced in .NET, there were things that he wouldn't think of that ColdFusion developers take for granted -- "things like calling out to functions but still using the cfset tag, and trying to figure out whether parameters could even be passed and then how to do it, by value or by reference." He compared this mind shift to his experiences doing serious Unix shell programming when coming from a programming language background. However, once he got into the mindset, he seems to have found ColdFusion easy to use. In his blog entry, he notes, "the fact that I was able to become mildly proficient in a new environment and prepare my examples for the presentation is a great testament to the platform!"

Teaching Test Driven Development

Why was Jonathan willing to go through the hoops of learning another language just to spread the word about TDD? In our talk, his passion for TDD was obvious. "This methodology is not for process, schedule or planning of coding but for the actual line by line stuff. It changes how you write each line of your code and has enormous impact on the developer work day; this is radical!" Test Driven Development requires the programmer to write tests for each feature before he or she writes that feature. "The end result is a powerful regression testing suite for EVERY feature in the system." Jonathan said he views TDD as essential in this age of more complex development platforms and applications that are increasingly more sophisticated. "Manual testing is not cost effective or quick enough for the market today. TDD also has wonderful benefits of encouraging other great practices such as coding standards, continuous builds and pair programming. TDD is a reliable method to break down complexity and build confidence in your code base."

Jonathan has been practicing TDD for a little over three years, and learned about it through a fellow .NET community supporter, Steven Smith of AspAlliance, who got Jonathan "thirsty enough to want to know more." He was converted to TDD through available literature, community newsgroups and lots of coding.

Jonathan notes that teaching TDD can be tricky. "TDD is a tricky thing to present since it is not an output but rather a process. That means you have to do it to explain it. A common idea in the TDD community is to 'pair with the newcomer'; I typically extend this to mean 'pair with the audience' when presenting TDD."

Test Driven Development with ColdFusion

I asked Jonathan to compare doing TDD with ColdFusion to doing it with .NET, but he said wasn't qualified to give a fair comparison. "I have only spent a few hours working in ColdFusion, whereas I have spent several years working in .NET." He did compare CFunit to JSUnit, a "wonderful" unit testing framework for Javascript. "It requires a browser and you have to hit refresh to run your suite. This tends to make for a poor test runner compared to something such TestDriven.NET that is integrated with your IDE."

He suggested that ColdFusion developers run their unit tests in batch through some sort of build tool (such as Ant in Java, or Nant in .NET). "A mechanism exists in JSUnit for doing exactly this and I wouldn't be surprised if something has been created for CFUnit or will be soon. The unit testing space in ColdFusion still looks rather new so watch out for ports from other platforms and see how things can be done differently to better take advantage of ColdFusion's strengths." He noted that this had happened in the .NET community. Nunit was ported from Junit (Java) in 1.0 for use with .NET, but has grown to be a more powerful implementation in 2.0, which really harnesses the features of .NET. [Editor's Note: Since this interview took place, Robert Blackburn has created CFUnit-Ant, which he will cover in Part III of his article on CFUnit and TDD in an upcoming issue of Fusion Authority.]

Final Thoughts

In the web development business, we often see things posed as a conflict between languages and technologies: PHP vs. ColdFusion or .NET vs. ColdFusion. With his experience, Jonathan Cogley has proven that good programming techniques, such as TDD, transcend languages and can help bridge the gap between two different development communities.
If you'd like to learn more about Test Driven Development, you can read Part I of our series on "Test Driven Development with ColdFusion" by Robert Blackburn.

Privacy | FAQ | Site Map | About | Guidelines | Contact | Advertising | What is ColdFusion?
House of Fusion | ColdFusion Jobs | Blog of Fusion | AHP Hosting