CB3 / MXUnit / integration testing

Hi,

I'm familiar with MX unit and testing individual objects, but I'm
looking at doing integration testing. I'm running the tests against
the latest version of Coldbox from SVN and MXUnit as an Eclipse
plugin.

The problem that I have is that when I run event =
execute("Account.index") the event collection doesn't seem to contain
objects.

For example to test this handler:

  void function index( required event )
  {
    var rc = event.getCollection();

    rc.validationresult =
instance.ValidationService.getValidator().newResult();

    if ( structKeyExists( rc, "message") )
    {
      rc.validationresult.setSuccessMessage( rc.message );
    }

    event.setView( "account/index" );
  }

this works:

  function testIndex()
  {
    var event = "";

    url.message = "hello world";

    // Execute Event
    event = execute("Account.index");

    assertTrue( event.valueExists( "message" ) );
    assertTrue( event.getValue( "message" ) eq url.message );

  }

But this doesn't

  function testIndex()
  {
    var event = "";

    url.message = "hello world";

    // Execute Event
    event = execute("Account.index");

    assertTrue( event.valueExists( "validationresult" ) ); <- fails here

  }

Am I doing something wrong?

Thanks,

- John

I think you will need to get the collection again, or at least reference it
with the prefix rc.

Thanks Andrew.

I did originally have rc = event.getCollection() in the test, but that didn’t work so I went as simple as I could to see what was causing it. I think I’ll have to step through the code and see if I can spot what is going on.

Cheers,

  • John