I’m just starting to use CB and MXUnit and thought I would start by testing my models. My list and get methods word find but but when I try use model.save() in the update method MXUnit reports the following error. ColdBox Controller Not Found
The coldbox main controller has not been initialized
void function list() {
var result = model.list();
assertIsQuery( result );
}
void function get() {
var result = model.get( 14 );
//Get an invalid user ID number.
assert( isNull(result) );
//Get a valid user ID number.
result = model.get( 148 );
assert( not isNull( result ) );
assertEquals( result.getuser_id(), 148, “Error getting user id” ); //Check that the id number can be retrieved.
}
void function update() {
//Get a valid user ID number.
var result = model.get( 148 );
assert( not isNull( result ) );
// FILL OUT: THE LOCATION OF THE CONTENTBOX MODULE
rootPath = replacenocase(replacenocase(getDirectoryFromPath(getCurrentTemplatePath()),“test\”,""),“test/”,"");
The Application.cfc should be kept at a minimum, then what you need to do is have that application.cfc extend your root application, this is not the way I do it but it looks like that is your problem.
So you might understand it better, because you are extending ColdBox in the Application.cfc, this basically is the working directory and ColdBox is trying to find the configuration from the current directory.
Which doesn’t exist, and the error reflects that.
I am not sure if you are using Eclipse with CFEclipse or CFBuilder, but either way you will be better setting up the remote facade for mxunit in there, gives greater control on running your tests inside your ide. I find this a better method for productivity.