coldbox mxunit autowire question

6 views
Skip to first unread message

jim collins

unread,
Jun 20, 2009, 10:11:53 PM6/20/09
to ColdBox Framework
Im using MXunit and theres a service object that gets autowired by
coldbox. How, in the test, do I tell coldbox "autowire the object and
give it to me"?

Luis Majano

unread,
Jun 21, 2009, 3:29:14 PM6/21/09
to col...@googlegroups.com
Can you expand your question, what are you trying to do and where?
--
Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldboxframework.com
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

jim collins

unread,
Jun 24, 2009, 12:00:46 PM6/24/09
to ColdBox Framework
I have an MXUnit test. I want to test the service object. The service
object uses ColdBox autowiring to set various things.
AFAIK this prevents me from using createobject in the MXUnit test as I
normally would.
In the Handler it looks like simply putting "<cfproperty
name="ServiceObject="model:ServiceObject" /> is enough to make Coldbox
create it w/the autowiring. If I put that line in my MXUnit file I get
an error "Element CBCONTROLLER is undefined in APPLICATION" . So my
question is how to I get access to an autowired object in my MXUnit
test?
BTW the MXUnit object extends
"coldbox.system.extras.testing.baseMXUnitTest"
Thanks,
Jim


On Jun 21, 3:29 pm, Luis Majano <lmaj...@gmail.com> wrote:
> Can you expand your question, what are you trying to do and where?
>

Luis Majano

unread,
Jun 24, 2009, 2:00:50 PM6/24/09
to col...@googlegroups.com
Jim,

Are you wanting to test the object without its dependencies, thus mocking it's dependencies?

Or do you want to test it with its dependencies and wirings?

This is key in to what approach you take!!

ColdBox supports both with the introduction of MockBox.  I myself usually test my model objects without external dependencies, and if they need some then I use MockBox to mock them to make my testing easier and nicer.

http://blog.coldbox.org/post.cfm/mocking-objects-with-coldbox-annotations

I would give MockBox a shot. You can easily install it via Daily Build on coldbox 3.0.

Also, the base test cases, have a getModel() method that can give you the object for testing.  3.0 really capitulizes on unit testing and will have even more support for this.  Most of it is already on SVN for testing.

This way, you can test with or without loading the virtual application.

jim collins

unread,
Jun 26, 2009, 3:47:30 PM6/26/09
to ColdBox Framework
Thanks Luis, getModel() in the mxunit test worked like a charm.

On Jun 24, 2:00 pm, Luis Majano <lmaj...@gmail.com> wrote:
> Jim,
>
> Are you wanting to test the object without its dependencies, thus mocking
> it's dependencies?
>
> Or do you want to test it with its dependencies and wirings?
>
> This is key in to what approach you take!!
>
> ColdBox supports both with the introduction of MockBox.  I myself usually
> test my model objects without external dependencies, and if they need some
> then I use MockBox to mock them to make my testing easier and nicer.
>
> http://blog.coldbox.org/post.cfm/mocking-objects-with-coldbox-annotat...
Reply all
Reply to author
Forward
0 new messages