« Return to Thread: Mocking, expectations

Re: Mocking, expectations

by Nat Pryce :: Rate this Message:

Reply to Author | View in Thread

JMock is a tool for testing how an object communicates with it's peers.

If you need to test only part of an object's internal implementation,
that's a good indication that the object is too complicated should be
split into two or more collaborating objects.

--Nat

On 29/03/2009, Indrek Juhkam <indrekju@...> wrote:

> Hey,
> Okay. It seems so.
>
> In ruby with rspec I could do:
> plugin = HelloPlugin.new
> plugin.should_receive(:send_and_create_message).with("Tere inimene")
> msg = Message.new
> msg.params[0] = "Inimene"
> plugin.do_work(msg)
>
> How can I get similar behavior?
>
> On Sun, Mar 29, 2009 at 5:27 AM, Nat Pryce <nat.pryce@...> wrote:
>> You're not actually testing anything in that test because you're
>> mocking the object that you're testing.
>>
>> --Nat
>>
>> On 28/03/2009, Indrek Juhkam <indrek@...> wrote:
>>> Hey.
>>>
>>> I have problem with JMock. Can somebody say what's wrong
>>> http://pastie.org/429898 .
>>> I'm used to use rspec and mocha in Ruby. So Java seems very strange
>>> sometimes :).
>>>
>>> Indrek
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>     http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>>
>> --
>> http://www.natpryce.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>


--
http://www.natpryce.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Mocking, expectations