Mocking transfer mean

Forgive me if this makes no sense; I'm trying to get my head around
unit testing / mocking.

I'm trying to write a test for my model's saveBox function. It takes
a transfer bean of type - checks if it is valid then saves it
(using boxService) or throws an error.

So how would I go about mocking a transfer bean? Or am I getting the
wrong end of the stick?


My test so far:

<cfcomponent extends="coldbox.system.testing.BaseModelTest"

  <cffunction name="setUp" returntype="void" output="false">


    boxModel = getMockBox().createMock(className="model.BoxModel");


  <cffunction name="testSave" returntype="void" output="false">

    box = // mock transfer object here and set some properties on it?

    boxModel.saveBox(box );



you can do two things

  1. Mock a transfer object
    box = getMockBox().createEmptyMock(“”)
    // check the paths, I am not sure

  2. Create a stub object
    box = getMockBox().createStub();

Then mock properties on it.

That’s it!

Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager:

Thanks very much for the reply. I'll give that a go!