From: Vincent M. <vm...@pi...> - 2003-05-16 07:27:49
|
> > -----Original Message----- > > From: Tim Mackinnon [mailto:tim...@po...] > > Sent: 16 May 2003 01:36 > > To: Vincent Massol > > Subject: RE: [MO-java-dev] [New DynaMock] Why is there no match() > method? > > > > Now you are on to something! > > > > For methods with no return type - do we want a mock type that doesn't > > care? > > (If there is a return type I think its dangerous to provide a default > > value > > as this smells of missing tests - and a lack of documentation via a > test.) > > - > > however void methods are interesting. Should you have to be specific? > > > > I am warming to the idea of match(...) (its kind of an ignore() but > that > > introduces another name so match() seems good). If you did this in > setUp, > > then if you really care you put an expect in a test which would take > > precendence. I like this behaviour - I've seen this before, you > shouldn't > > get hosed for having defaults in a setUp method but can be more > precise > > when > > you want to. > > > > You could add this vincent - its pretty straightforward. I would > suggest > > also augmenting the SimpleServletTest to show this - as its our > functional > > test at the moment. An interesting suggestion but I'd prefer if it is someone who has been involved in writing the new DynaMock who does it. I'm starving for time right now (I shouldn't even have enough time to get involved in the mockobjects project at all :-)). This I greatly appreciate if one of you could add this... I've added it as a feature request in SF: https://sourceforge.net/tracker/index.php?func=detail&aid=738667&group_i d=18189&atid=368189 Thanks -Vincent > > > > Tim > > > > > -----Original Message----- > > > From: moc...@li... > > > [mailto:moc...@li...]On Behalf > Of > > > Vincent Massol > > > Sent: 15 May 2003 09:45 > > > To: 'Joe Walnes' > > > Cc: moc...@li... > > > Subject: RE: [MO-java-dev] [New DynaMock] Why is there no match() > > > method? > > > > > > > > > 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 > > > > >> > > > > >> > > > > >> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa > Clara > > > The only event dedicated to issues related to Linux enterprise > solutions > > > www.enterpriselinuxforum.com > > > > > > _______________________________________________ > > > Mockobjects-java-dev mailing list > > > Moc...@li... > > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > > > > > > --- > > > Incoming mail is certified Virus Free. > > > Checked by AVG anti-virus system (http://www.grisoft.com). > > > Version: 6.0.476 / Virus Database: 273 - Release Date: 24/04/2003 > > > > > --- > > Outgoing mail is certified Virus Free. > > Checked by AVG anti-virus system (http://www.grisoft.com). > > Version: 6.0.476 / Virus Database: 273 - Release Date: 24/04/2003 > > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > The only event dedicated to issues related to Linux enterprise solutions > www.enterpriselinuxforum.com > > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev |