I’m trying to run my MXUnit tests using TestBox, using the DirectoryTestSuite runner, like so:
<cfset r = new testbox.system.testing.compat.runner.DirectoryTestSuite()
.run( directory="#expandPath( ‘/tests’ )#",
#r.getResultsOutput( ‘simple’ )#
Unfortunately some of my tests are rather slow, and timing out with the message “The request has exceeded the allowable time limit Tag: cfoutput”.
Putting something like:
in the above file seemed to keep MXUnit happy, but it looks like I actually need to put this into testbox/system/testing/reports/assets/simple.cfm
Is there a best practice for running a mass of tests like this? What do other folk do?
You can actually put it in any template. I would put it in the runner code
If your unit tests are taking that long you either have an incredibly large test suite or you’re doing too much in your tests
Unit testing a single method with all external dependencies mocked, should only take a few milliseconds. Now if you’re actually doing more integration tests then they might be slower.
There’s no best practice for slow test-- I’d say your request timeout is the first thing you can do. If it were me, I’d take a look at some stack traces with Fusion Reactor and see just what those tests are doing that’s taking so long. You may find some expensive stuff in your setup and tear down that you can optimize.
Another option, is to break them up and run only part of them at a time.
ColdBox Platform Evangelist
Ortus Solutions, Corp
ColdBox Platform: http://www.coldbox.org
Yeah I test my DAO layer by executing the SQLs against a test database (and some are fairly lengthly queries). Don’t other people do this?
I use mocks on my service classes to check that the expected DAO layer calls are being made, but I also like to execute the SQLs to ensure that the syntax is valid, and that any future schema changes don’t mess me up.
Luis - when you say to put the timeout in the “runner code”, I am pretty sure that’s what I’ve done. This is the “runtests.cfm” file:
<cfsetting requestTimeOut = "300"> <cfset r = new testbox.system.testing.compat.runner.DirectoryTestSuite() .run( directory="#expandPath( '/tests' )#", componentPath="tests" )> <cfoutput>#r.getResultsOutput( 'simple' )#</cfoutput>
But it’s still dying with the message:
The request has exceeded the allowable time limit Tag: cfoutput
The error occurred in C:/jboss/jboss-5.1.0.GA/server/risedev/deploy/cfusion.ear/cfusion.war/testbox/system/testing/reports/assets/simple.cfm: line 1
Called from C:/jboss/jboss-5.1.0.GA/server/risedev/deploy/cfusion.ear/cfusion.war/testbox/system/testing/reports/SimpleReporter.cfc: line 53
Called from C:/jboss/jboss-5.1.0.GA/server/risedev/deploy/cfusion.ear/cfusion.war/testbox/system/testing/TestBox.cfc: line 270
Called from C:/jboss/jboss-5.1.0.GA/server/risedev/deploy/cfusion.ear/cfusion.war/testbox/system/testing/TestBox.cfc: line 96
Called from C:/jboss/jboss-5.1.0.GA/server/risedev/deploy/cfusion.ear/cfusion.war/testbox/system/testing/compat/runner/Results.cfc: line 32
Called from C:/jboss/jboss-5.1.0.GA/server/risedev/deploy/cfusion.ear/cfusion.war/tests/runtests.cfm: line 5
I might need to break them up like Brad suggested. I’ll keep thinking
Just breaking it down and it looks like it’s really hitting limit of 300 seconds, so the timeout might be getting setting correctly after all. I’d say the tests probably would have timed out on my local machine on MXUnit also - I haven’t run them there for a while as they’re usually run via Jenkins and they probably run a lot faster there (I am connected via a VPN when I run them locally).
So - what I might do is create a few runners so that I can just run locally what I am currently interested in.
Thanks for your time guys. I think we’re all good now.