[coldbox:16644] MX Unit reports coldbox main controller has not been initialized

What URL are you hitting? If you are hitting a URL in the test folder and it extends ColdBox, then the ColdBox framework will attempt to start up which is not what you want for unit tests. My limited unit test experience is with the directory runner which is in the MXUnit folder. That folder has an Application.cfc that doesn’t do any ColdBox stuff. That way the tests can create my models completely outside of the framework life cycle.



I have been accessing it through the following URL http://localhost:8500/app2/test/unit/UserTest.cfc?method=runTestRemote.

The get and list functions pass but the add_delete fails on the call to save().

I’m using both CFBuilder and CFEclipse. I finally got MXUnit working on CFEclipse and it reports ColdBoxProxy.ControllerIllegalSate: ColdBox Controller Not Found The coldbox main controller has not been initialized.

Why does the ORM list & get work but not the save?



I ran across the same issue today. In my case, it looks like the root of the issue relates to the ORM Event Handler (particularly, postNew()) for creating new entities. I stole the fix by plagiarizing (to some extent) what’s being done in the core ColdBox tests:

// mock the EventHandler for methods with ORMEvents
mockEventHandler = getMockBox().createEmptyMock( “coldbox.system.orm.hibernate.EventHandler”);
// mock methods


// mock property


I’m still figuring out testing within ColdBox myself, so I can’t say that this is the best or right way to do this. All I know is that I had the same error as you, and by mocking the ORM EventHandler, I was able to get things to start succeeding.