Since a couple of folks have heard me talk about this and asked me to blog the 'how to' I figured that even in advance of Paul officially releasing this, I'd go ahead and explain what you can do with it and how easy it is to set it all up.
In the new release, cfcUnit adds a JAR file that defines a task in ant. To use it in a build.xml, you need to define the task:
Then you can define a test case target like this:
<cfcUnit hostname="${hostname}" testcase="com.adobe.hs.test.suite" verbose="false"/>
</target>
Note how my test target depends on my deploy target so updated code is automatically deployed before the test suite is run.
Now I can just execute the test target and cfcUnit will run my test suite (in the example, the suite is the CFC /com/adobe/hs/test/suite.cfc).
That's the first step.
The real power is that I can now set up Eclipse to run the test suite automatically every time I change any file in my project!
In Eclipse, right-click on your project and select Properties. In the properties dialog, select Builders and then click New... and then select Ant Build. In the Main tab, select your build.xml file (by browsing your project workspace). Then in the Targets tab, choose Set Targets... for the Auto Build and pick which target to execute. Next - very important! - in the Classpath tab, click on User Entries and then Add External JARs... and navigate to your ant-cfcUnit.jar file. Finally, in the Build Options tab, enable Launch in background (and make sure Allocate Console is enabled too). OK, you're done.
Whenever you refresh the project, add a new file or save changes to an existing file, Eclipse will run the specified target in the build file. In my case, that auto-deploys any changed files to my localhost setup and then runs a verbose test suite. I get to see all the results in my Console window in Eclipse. Awesome!
Verbose test? Ah, I only showed the simple test suite target above. Here's the verbose one:
<cfcUnit hostname="${hostname}" testcase="com.adobe.hs.test.suite"
verbose="true"
haltonfailure="true"
haltonerror="true"
showstacktrace="true"/>
</target>
My workflow is now: edit the test harness, add a new test case, save. Auto-deploy, auto-test, failure. Now edit the application code to add logic to pass the test case, save. Auto-deploy, auto-test, pass. Rinse and repeat.
And here's the sort of output you get from the verbose test:
deploy:
[copy] Copying 1 file to /www
verboseTest:
[cfcUnit] URL: http://localhost:8300/cfmx/cfcunit/XmlService.cfm? -testclassname=com.adobe.hs.test.suite
[cfcUnit] Running : com.adobe.hs.test.suite
[cfcUnit] Tests Run : 24
[cfcUnit] Failures : 0
[cfcUnit] Errors : 0
BUILD SUCCESSFUL
Total time: 3 seconds
The only reason I used cfUnit was the ant integration. Now that cfcUnit has ant integration, I've dumped cfUnit completely.


