MXUnit Configuration

I am having some trouble getting MX Unit configured to work with ColdBox under Eclipse.

ColdBox v3.1.0
MXUnit v2.1.1
Tomcat v7.0.23
Railo v3.3.1
Mac OSX v10.7.3

I belive that have configured the default installation settings and the project being run from the root directory (http://localhost:8080/index.cfm/home/aboutsite).

http://localhost:8080/
/coldbox
/config
/handlers
/mxunit
/test/integration/HomeTest.cfc

The project is configured with the URL http://localhost:8080/mxunit/framework/RemoteFacade.cfc?wsdl which passes the test from the MXUnit Properties window.

Here is the content of my test case HomeTest.cfc:

component extends=“coldbox.system.testing.BaseTestCase” {
public void function setUp() {
//Setup ColdBox Mappings For this Test
setAppMapping(ExpandPath( “…/…/”));
setConfigMapping(ExpandPath(instance.AppMapping & “config/Coldbox.cfc”));

// Call the super setup method to setup the app.
super.setup();
}

public void function testPlain() {
assertTrue(true);
}
}

When I run the test, the MXUnit plug in shows success, but the Tomcat console reports the following error message:

key [cbController] doesn’t exist in struct (keys:applicationname,wireBox)
at railo.runtime.type.util.StructSupport.invalidKey(StructSupport.java:30):30
at railo.runtime.type.StructImpl.get(StructImpl.java:78):78
at railo.runtime.type.util.StructSupport.get(StructSupport.java:125):125
at coldbox.system.coldbox_cfc$cf.udfCall1(/Users/brian/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Railo_3_3_1/coldbox/system/Coldbox.cfc:395):395

If I change the test case to include a call to getRequestContext(), the test case succeeds and the RequestContext is displayed in the output, but the same error is given in the Tomcat console.

public void function testPlain() {
local.rc = getRequestContext();
debug(local.rc);
assertTrue(true);
}

If I change the test case to include a call to execute() such as the one below, then the test fails with the error “railo.runtime.exp.Abort: Page request is aborted”, but the Tomcat console does not show an error message.
public void function testPlain() {

execute(“home.aboutSite”);
assertTrue(true);
}

Additionally, once I run any of these test cases, the MXUnit Plugin “Test Facade URL” fails with the key [cbController] doesn’t exist in struct (keys:applicationname,wireBox) error until I restart the server.

So, what do I not have configured correctly?

Brian

You are pointing the facade to he mxunit folder and not your test folder this two different application scopes.

When running from eclipse the mxunit plugin talks to a location via web services to run your tests. It needs the right application.cfc to execute and the right facade.

We include one in te templates and also a test application.cfc. Point it there

Luis,

Thanks, that helped me get passed the cbConroller issue.

  • Changed the MXUnit project settings to use the Remote Facade included in the test/resources directory (http://localhost:8080/test/resources/RemoteFacade.cfc?wsdl)
  • From the ColdBox Distribution I copied \ApplicationTemplates\Advanced\test\Application.cfc to my project’s /test directory.

I am now able to run a basic test without error and I can even interact with a Model object. However, I can still not execute an event. In the test case below, modelTest is successful, but executeTest fails with a “railo.runtime.exp.Abort: Page request is aborted” error.

component extends=“coldbox.system.testing.BaseTestCase” {
public void function setUp() {
setConfigMapping("/config/Coldbox.cfc");

// Call the super setup method to setup the app.
super.setup();
}

public void function executeTest() {
local.event = execute(“home.aboutSite”);

assertTrue(true);
}

public void function modelTest() {
local.user = getModel(“User”).findByKey(1, false);
debug(local.user.getUsername());

assertEquals(local.user.getUsername(), “brian”);
}
}

You are pointing the facade to he mxunit folder and not your test folder this two different application scopes.

When running from eclipse the mxunit plugin talks to a location via web services to run your tests. It needs the right application.cfc to execute and the right facade.

We include one in te templates and also a test application.cfc. Point it there

Check if you have an abort somewhere

I searched the code and did not find any aborts so I thought that the best approach would be to take some time and try to isolate the problem. I replaced my code with one of the sample applications and the test cases from the sample application worked fine. I then started adding in my application code back in until I encountered the issue. It turns out that the cause was having setUniqueURLs() set to true in the Routes.cfm file. I set that value to false and now all 100+ test cases work fine.

Brian

Check if you have an abort somewhere