Error using coldbox.system.testing.BaseHandlerTest

I’m trying out the new BaseHandlerTest but running into problems. It appears to be a problem with the test not being able to find the controller when executing events.

I get the following error:

The getSetting method was not found.
Either there are no methods with the specified method name and argument types or the getSetting method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.

I shrunk down the stack trace a bit.

C:…\system\testing\BaseTestCase.cfc (336)
C:…\system\testing\BaseTestCase.cfc (355)
C:…\BH\test\handler\GeneralTest.cfc (32)

I only get this error when I use the execute method to run an event. I’m not sure what is going on but after digging through the code for BaseHandlerTest and BaseTestCase it appears that the controller is never being setup. If I do a dump of getController() I get “0” which is the default value for instance.controller. And of course, getController() returns instance.controller.

In BaseHandlerTest, variables.mockController is setup but I’m not sure if it is the same instance.controller in BaseTestCase.

Am I setting up something incorrectly or is this a bug? I’m guessing I’m doing something wrong but I can’t put my finger on it.

The base handler, plugin and interceptor tests just setup everything you need so you can start testing. It does not init() the plugin, handler or interceptor because there could be dependencies on those methods that need mocking, etc.

Therefore, you will need to init() the handler/plugin in your tests setup() methods.

Also, you cannot use the “execute()” method anymore because you are not doing integration testing but direct handler testing. This means that you are no longer testing a virtual coldbox application but just a handler CFC. If you are doing direct handler CFC testing, then you will just execute the method directly like normal unit testing.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com