G’day:
I’m only using TestBox to replace MXUnit at the moment, rather than using it in anger.
I’m writing some tests for some code I am about to write, so they all currently error (calling a function that doesn’t exist). This is cool, it’s what I want.
However when I run the tests, I get this error from within TestBox:
Variable ISEXPECTEDEXCEPTION is undefined.
coldfusion.runtime.UndefinedVariableException: Variable ISEXPECTEDEXCEPTION is undefined. at coldfusion.runtime.CfJspPage._get(CfJspPage.java:316) at coldfusion.runtime.CfJspPage._get(CfJspPage.java:296) at coldfusion.runtime.CfJspPage._get(CfJspPage.java:284) at cfBaseSpec2ecfc697396152$funcRUNTESTMETHOD.runFunction(C:\apps\adobe\ColdFusion\10\cfusion\wwwroot\frameworks\testbox\1.0.0\testbox\system\testing\BaseSpec.cfc:469) at
[etc]
testbox\system\testing\BaseSpec.cfc; line 469
The code in question is this:
try{
evaluate( “this.#arguments.spec.name#()” );
}
catch( Any e ){
if( !isExpectedException( e, arguments.spec.name, arguments.runner ) ){ rethrow; }
}
(BTW: evaluate()? Seriously? Anyway…)
And, as Brad pointed out to me on Twitter, isExpectedException() is defined and alive and well at line 672:
private boolean function isExpectedException( required exception, required specName, required runner ){
So this should be no problem.
I don’t think is this anything to do with my code, but for the sake of completeness, 'ere 'tis (also on Github @ https://github.com/daccfml/scratch/tree/master/blogExamples/unittests/testbox)
// Application.cfc
component {
this.mappings = {
“/testbox” = expandPath("/frameworks/testbox/1.0.0/testbox"),
“/mxunit” = expandPath("/frameworks/testbox/1.0.0/testbox/system/testing/compat")
};
}
#new testbox.system.testing.TestBox( bundles="Tests" ).run( reporter="simple" )#// Tests.cfc
component {
public void function beforeTests(){
variables.beforeTestsRun = true;
}
public void function setup(){
variables.setupRun = true;
}
public void function testInitFunctions(){
assert(structKeyExists(variables, “beforeTestsRun”));
assert(structKeyExists(variables, “setupRun”));
}
public void function testThatErrors(){
throw(type=“TestException”, message=“This is a test exception”, detail=“Note that it is NOT being caught / tested for. This is by design”);
}
}
This is a repro case, not the actual test I was having problems with, but the behaviour is the same.
It could be an install problem (although it really just seems like weirdness!), and the details of my install are here: http://cfmlblog.adamcameron.me/2013/12/unit-testing-tdd-switching-off-mxunit.html
That’s a long article, but the basics are that it’s not installed in the default recommended /testbox dir in my webroot, but in a separate dir, with a CF mapping to point to /testbox. I have also followed the instructions for remapping /mxunit.
Tests that should pass do pass. I’ve just noticed that tests that fail (as opposed to erroring) also give the error above. And tests that error behave as described here.
This is running on ColdFusion 10,0,12,286680, enterprise licence.
I’m having some trouble getting Railo to see Testbox, but will check that out and see what it says… and post back. Must dash…
Any ideas?