Make the CFWheels test framework return jUnit XML
JUnify will run your CFWheels unit tests, then return the results in jUnit formatted XML. Use it for automated testing with your Continuous Integration server.
Following the road to jUnit Glory
- Download and install the JUnify plugin from CFWheels or GitHub
- Create a JUnifyController.cfc controller that calls the JUnify() function*
- Write some unit tests for your app or plugin
- Make a call to your JUnify url
* Controller filename and action names are unimportant
JUnifyController.cfc
<cfcomponent extends="Controller"> <cffunction name="index"> <cfset JUnify(params)> </cffunction> </cfcomponent>
Your JUnify URL
http://yourserver/index.cfm?controller=junifycontroller&action=index&type=app
Pay particular attention to the type parameter.
– type=app will run tests for your application
– type=myplugin will run tests for your plugin
– type=core will run tests for the CFWheels framework itself
Props to Rocketboots for their RocketUnit test framework
Very nice and simple plugin. Love it. I have spotted an issue which I cannot explain. I have an action in a controller which redirects but jUnify just does not seem to return correct output.
In my test:
The jUnify output is blank. The browser does not display anything.
However, if I view page source, the testsuite is wrapped in html body.
If I comment out the processAction line, it works fine.
The idea is that I want to catch the redirect and evaluate the destination.
Am I using the Plugin in a way that I should not be used?
Regards,
Hi! Thanks for trying the plugin..
The plugin’s purpose is to just to return the cfwheels test framework results in JUnit format. I would try running the same tests in the CFWheels test UI. If the redirect is still causing problems in the CFWheels test UI, then it may be something in your tests or your controller.. This has usually been the case for me as the plugin doesn’t interfere with the test framework’s innards.. just returns the results differently.
When testing redirecTo(), the biggest culprit is usually forgetting to use the delay=true argument.
I’ve also found some quirks when testing apps using the coldroute plugin.
Most of my controllers and tests revolve around these Scaffold templates that I wrote..
https://github.com/chapmandu/scaffold-chapmandu/blob/master/chapmandu/controller.cfm
https://github.com/chapmandu/scaffold-chapmandu/tree/master/chapmandu/tests
All the best!
Adam,
Thanks for a swift response. To tell you the truth, that’s what adds to the confusion: my CFWheels test UI output is fine and there are no issues with redirection. I have used the delay=true on every redirection in this particular action.
It is fair to note that the jUnify output is produced, it just gets wrapped in html body thus not displayed in browser.