« Return to Thread: Ignoring all mock method calls EXCEPT certain ones

Re: Ignoring all mock method calls EXCEPT certain ones

by Nat Pryce :: Rate this Message:

Reply to Author | View in Thread

Please read

http://www.jmock.org/dispatch.html 

And

http://www.jmock.org/match-object-or-method.html

Cheers,
    Nat

www.natpryce.com

On 27 Mar 2009, at 15:15, "Lawson, Robert W" <robert.w.lawson@...> wrote:

I want to set an expectation that a particular method (or methods) on a mock are called, but ignore any other methods that are called on that mock.  Ive read some posts that say this is easily done by something like:

oneOf (foo).doIt(45);

ignoring (foo);

However, this ignores all calls to the foo mock, including the doIt() method.  The only thing I can do right now to get my test to work is to not use ignoring, and set an expectation on EVERY method of foo that is called.  If I dont, when any method other than doIt() is called, an unexpected method invocation exception is thrown.

Im sure there has to be an easy answer to this.  Can anyone help?

 « Return to Thread: Ignoring all mock method calls EXCEPT certain ones