From: Vincent M. <vm...@pi...> - 2003-05-15 08:45:47
|
Ok. Here's use case: I have in my code a call to queueConnection.close() (for example). I use a Mock for QueueConnection. If I *don't* define either an expect*() or a match*(), I get: junit.framework.AssertionFailedError: mockQueueConnection: Unexpected call: close() Expected no methods at com.mockobjects.dynamic.Mock.invoke(Mock.java:95) [...] Which means to me that we have to define the behaviour for any method called (and that there is no default behaviour assumed). Fine with me. Then, I don't want to set an expectation on close() because this mock setup is part of a general setup that I want to reuse across several tests and some tests do call close(), some do not. But there is no match() method. Basically I'd like to simply tell DynaMock that I don't care about this close() method. ATM, I've tricked it, by using: mockQueueConnection.matchAndReturn("close", null); But that seems like a hack (or even a DynaMock bug) to me. Am I not thinking in the right direction? Thanks -Vincent > -----Original Message----- > From: Joe Walnes [mailto:jo...@tr...] > Sent: 15 May 2003 09:03 > To: Vincent Massol > Cc: moc...@li... > Subject: Re: [MO-java-dev] [New DynaMock] Why is there no match() method? > > That's right. There's no reason to use match if you're not trying to > setup a return value. You can still use expect in the same way to setup > return values which also have expectations on the method calls. > > Vincent Massol wrote: > > >Hi Joe, > > > >I thought the only difference between match*() and expect*() was that > >expected methods were setting expectations that were verified when you > >call the verify() method on the mock? > > > >Also, expectAndReturn() does also setup return values, right? > > > >Thanks > >-Vincent (Still confused by the difference between match*() and > >expect*() :-)) > > > > > > > >>-----Original Message----- > >>From: Joe Walnes [mailto:jo...@tr...] > >>Sent: 14 May 2003 21:38 > >>To: Vincent Massol; moc...@li... > >>Subject: Re: [MO-java-dev] [New DynaMock] Why is there no match() > >> > >> > >method? > > > > > >>Vincent Massol wrote: > >> > >> > >> > >>>Hi, > >>> > >>>There is an expect() method (replacing the old expectVoid()), but > >>> > >>> > >there > > > > > >>>is no match() method. Any reason? > >>> > >>> > >>> > >>> > >>The only use of match() is to setup return values - so it's not needed > >>for void methods. > >> > >>-joe > >> > >> > >> > > > > > > > > > |