TerrenceRyan.com

I'm a 35 year old redhead geek from Philly.
I'm currently a Developer Evangelist for Adobe.
Also the author of Driving Technical Change

Squidhead and CFUnit

7 Comments

I published a change to Squidhead earlier today that included an option for Squidhead to write its own unit tests today. These unit tests are compatible with and require CFUnit. Here's a little bit about the reasons behind this.

I originally started fooling around with unit testing because after drinking Pragmatic Programmer Kool-Aid, and attending cf.Objective, it was the next thing on my list. I figured I would be pulling them into Squidhead, as it's pretty easy to tell if Squidhead worked (the application is either written or not,) but it's hard to tell if the created application is working. So I started to write unit tests for my DAO Objects figuring it would be an easy place to start. Once I got one working, I realized it was relatively rule based and could stand to be generated itself.

What it does is:

All that is wrapped in a <cftransaction> making sure the thing never happened. Additionally it reads in and honors foreign key constraints. It's got some weaknesses: it doesn't like binaries or images; its smalldatetime check is only accurate to the hour; and there are probably more bugs lurking.

Now once I got them working, they were in, but what's the point for users of the application? One should expect that the parts work.

So to make this worthwhile I added some logic that will run any test that is in the test directory structure. So if you're using Squidhead and looking to dip your feet in the waters of CFunit or unit testing in general here's your chance.

If you're wondering why CFUnit, and not CFCUnit, it's because as far as I can tell CFCUnit requires Mach II, and I figured one requirement was better than two.

So if anyone has any suggestion on how to test gateways or dao's I'd be curious. Otherwise check it out.

7 responses so far ↓

  • 1 Sean Corfield

    cfcUnit does NOT require Mach II!!

    cfcUnit has ant integration, can be run by the CFUnit plugin for CFEclipse and the ASFusion folks created a Flex front end for it (which they could not do for CFUnit due to the poor architecture of the latter).

    cfcUnit also has an HTML "runner" application. That happens to be a Mach II application but uses a built-in version of the framework so you don't need to download or install anything other than Mach II.

    Adobe use cfcUnit extensively as do several other companies I've been dealing with lately. Having Squidhead generate cfcUnit test stubs would be far more valuable.
  • 2 Sean Corfield

    Argh! Typo:

    You don't need to "download or install anything other than cfcUnit." Sorry. See what happens when you get me frustrated?
  • 3 Terrence Ryan

    Sorry Sean, I didn't mean to make you angry. I was thrown off by the documentation on CFCUnit's site, on page: http://www.cfcunit.org/cfcunit/docs.cfm that states: "Before you install cfcUnit, you must be running CFMX 6.1 and the Mach-II (1.0.9) application framework."

    That being said. I'll take another look at CFCUnit. But I'm curious, not challenging, why CFCUnit? CFunit has Ant integration. CFUnit has an html runner and a front end. Is it the difference in architecture that you alluded to? Does CFCunit have better tests? (Which would definitely motivate me.)
  • 4 Robert Blackburn

    Hi Terrence,
    I noted a while back on my blog some of the differences I found between CFUnit and cfcUnit:
    http://www.rbdev.net/devblog/index.php?entry=entry051116-030332

    Since then I have also added a mock object CFC to the CFUnit framework - which I personally think is a very handy tool.

    In the end, I think both frameworks are very good. And I think the important think is just that you unit test at all, which framework you unit test with is secondary.
  • 5 Terrence Ryan

    Thanks Robert, that did shed some light on things.
  • 6 Nathan Mische

    I started to work on <a href="http://www.mischefamily.com/nathan/index.cfm/2006/11/16/Auto-Generating-Unit-Tests-With-cfcGenerator">auto generated unit tests with Brian Rinaldi's cfcGenerator</a> a while ago. I only got around to generating tests for Beans and DAOs as I couldn't figure out how to best populate the database to test gateways. One thing I'd be curious to know, do you test against a production database? What I ended up doing was having a blank scratch database, then I created and droped necessary tables in my setUp and tearDown methods. Looking back I don't know if that was a good idea or not.
  • 7 Terrence Ryan

    I'm only doing (and recommending) unit tests against development databases. I actually do all of the database stuff within an cftranaction that is rolled back. So the database is none the wiser.

Leave a Comment









Categories

Monthly Archives

Tag Cloud

coldfusion web development flex coldfusion builder appearances squidhead coldfusion builder extensions higher ed flash builder air mobile android adobe apptacular html5 driving technical change running a coldfusion shop adobemax06 movable type flash catalyst flash blackberry adobemax07 adobemax08 hero finicky css adobemax09 holy crap i’m a mobile developer centaur basecamp cfc unfuddle motorola metablog irrational characters ios git evangelism devices code reviews ant wharton subversion security phonegap philly philadelphia multidevice knowledge@wharton jobs browserlab adobemax10 adobe tv unfuddlecfc svnauth.cfc semantic html semantic html responsive web design qnx nlb linux jquery mobile java it github flexorg fireworks edge eclipse dreamweaver apps apple adobemax11