Mock Objects

23 views
Skip to first unread message

Joshua

unread,
May 18, 2011, 1:26:50 PM5/18/11
to mxunit
I have two components A and B. I am testing component B and I want to
mock component A which component B uses. How do I go about that?

Robert Rawlins

unread,
May 18, 2011, 1:42:55 PM5/18/11
to mxu...@googlegroups.com
Use a mocking framework to help you, check out MockBox, I've been using it recently and it's pretty solid.

Robert

Sent from my iPhone

On 18 May 2011, at 18:26, Joshua <j.glo...@gmail.com> wrote:

> I have two components A and B. I am testing component B and I want to
> mock component A which component B uses. How do I go about that?
>

> --
> You received this message because you are subscribed to the Google Groups "mxunit" group.
> To post to this group, send email to mxu...@googlegroups.com.
> To unsubscribe from this group, send email to mxunit+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mxunit?hl=en.
>

Bill Rawlinson

unread,
May 18, 2011, 1:48:04 PM5/18/11
to mxu...@googlegroups.com
Sorry to veer off on a tangent but every time I see Robert post I feel
like a relative is posting our last names are so similar. That is
all, now back to your regularly scheduled testing.

Joshua

unread,
May 18, 2011, 2:07:15 PM5/18/11
to mxunit
Thanks, I will check out MockBox.

On May 18, 12:42 pm, Robert Rawlins <rob...@supporttime.com> wrote:
> Use a mocking framework to help you, check out MockBox, I've been using it recently and it's pretty solid.
>
> Robert
>
> Sent from my iPhone
>

Randy Merrill

unread,
May 18, 2011, 2:19:22 PM5/18/11
to mxu...@googlegroups.com
Also check out MightyMock that is built in:


--
Randy Merrill

Joshua

unread,
May 18, 2011, 2:32:34 PM5/18/11
to mxunit
I tried using MightyMock but the mock object never gets called.

Joshua

unread,
May 18, 2011, 2:39:51 PM5/18/11
to mxunit
I can post a bunch of code showing what I did. My situation is quite
complex since one of the components actually returns a component from
one of the method calls via calling a stored procedure.

Joshua

unread,
May 18, 2011, 2:52:19 PM5/18/11
to mxunit
Wow just talking through my problem allowed me to solve my own issue.
Since my component that I was mocking was returning a component I had
to match the return type with the mock object returns(). Thanks for
everyone's time!

Robert Rawlins

unread,
May 18, 2011, 3:03:30 PM5/18/11
to mxu...@googlegroups.com
Haha I agree Bill, it always throws me off when I see you posting :-)

With regards to MockBox I have a post on Forrst which gives a simple insight into how to use it, feel free to take a look.

http://forrst.com/posts/Mocking_with_MockBox-9w3

Thanks,

Robert

Sent from my iPhone

Reply all
Reply to author
Forward
0 new messages