There are a number of people writing of the improvements in the
latest version of cfcUnit, and I have not been one of them. So, you
might be wondering why. Well, this last month since CFUnited, I have
been busy making cfcUnit 1.1 ready for full release. That means fixing
some bugs, adding some new assertions, and most importantly making sure
that there is some better documentation available. On top of all that,
though, I have been very busy making sure that you can run cfcUnit from
everyone's favorite build tool, Ant.
Apparently, the absence of a cfcUnit Ant task and the existence of
one for CFUnit has been a critical distinction between the two CF testing
frameworks, giving people a reason not to use cfcUnit. Well, at CFUnited
John Paul Ashenfelter took the initial stab at this elusive feature to
show that it could be done without too much effort using the
existing test runner that produces its results in WDDX.
There were a couple of problems with the first implementation, first
among them that JDOM was used to process
the XML document. This meant that when using the cfcUnit Ant task, you
had to first download and install the JDOM libaray (and any of its
subsequent dependencies) somewhere in the Ant classpath. A number of
people discovered just how difficult (and not to say tedious) this process
was for them just to get going.
Another problem was that the data format produced by the test runner was
WDDX, a format that isn't very friendly to someone trying to read using
XPath expressions since it really conveys no meaning at all to anything
besides another WDDX parser.
So, what did I do about this?
Well, the first thing I did was come up with a new XML grammar that
better describes the test results in a much more concise way. Once the
format was in nailed down, I wrote a test runner to produce that XML. Once
that was done, I needed to fix the problem posed by JDOM and its numerous
dependencies.
One thing that is nice about Ant is that it is configured using XML. In
fact, it uses Xerces and Xalan to process build configuration files, and I
figured the cfcUnit task could take advantage of the fact that by running
inside Ant it already has access to these libraries. So, after a bit of
work, the cfcUnit Ant task is now a lot easier to install without any
external libraries.
Now, some people might be wondering why I have gone to all this trouble
of producing XML in the test runner and parsing it in the Ant task. Why not
just format the text in ColdFusion and just display it in the console? Well,
there is a good reason for this, and its pretty simple really. By sending
raw data to the client, I can give the cfcUnit task a lot of options in
how it handles errors and failures in both the individual tests and in the
test runner itself. It can be configured to halt a build when something fails
or to keep going, or show a full formatted stacktrace generated by an error
inside a test.
Anyhow, after working with Ant for a little bit and seeing how Eclipse
can automatically run cfcUnit whenever a file is changed, I can see why
some people have gotten all bent out of shape because cfcUnit did not have
an Ant task, but I'm sure that will all change soon.
Anyhow, here are some of the things others have been saying about cfcUnit lately: