Monday, January 16, 2012

Using the New OrderedTestDecorator in MXUnit 2.1.1

One request that has come up frequently from users of the ColdFusion Koans was to have the ability to see the test results in order.  This weekend I created a new test decorator that will allow users to do just that, set the order of the test results via annotation.  Thinking it would be useful for others I opened a pull request on the MXUnit project and it was merged into the master branch on GitHub and added to the new 2.1.1 release.

In order to use the new decorator you must have MXUnit 2.1.1 or newer.  One way to check if you have the required decorator is to look in the mxunit/framework/decorators directory for the file OrderdTestDecorator.cfc.

In order to set the order of your tests two things have to happen.  The first is to add the custom decorator to you test component.

In a script based component the decorator is added like so:



In a tag based component you can add the decorator like this:



Once you have the annotation added to your test, you can start ordering them by adding the @order annotation to each test like so:

In a script based component the annotation looks like this:



In a tag based component it looks like this:



That's it, now your tests will run in the order you specified.
Fork me on GitHub