From: Vincent M. <vm...@pi...> - 2003-05-14 07:35:44
|
> -----Original Message----- > From: Tim Mackinnon [mailto:tim...@po...] > Sent: 14 May 2003 01:49 > To: Vincent Massol; 'Steve Freeman' > Cc: 'Mockobjects-Java-Dev' > Subject: RE: [MO-java-dev] First batch of questions on new Dynamic Mock > API > > > > Ok thanks. Then I don't understand the difference between match*() and > > expectAndReturn(). > > > > This appears to be a stumbling block - its exactly what steve said.. but > to > repeat: > > expect means: "To consider obligatory; require: e.g. The school expects > its > pupils to be on time." > match means: "One that is like another in one or more specified qualities: > He is John's match for bravery." > > > Thus - expectAndReturn means that it is obligatory for a certain call to > happen. We specify that call (becuase java does method overloading). And > we > also specify the result of that call. > > matchAndReturn means that we just specify a value that is like what would > happen if the real call had taken place. Note that we DONT set any > expectation. If the call doesn't happen then no failure would happen. > > In other words, its a return without any expectation, however in Java you > cannot create a method called "return(String name, Object return value)" > as > return is a reserved word. > > I can't think of any clearer way of saying this - does it help? It does... It would have been faster for you to just say "yes" to my question... :-). For example: Vincent: "what's the difference between expect*() and match*()? It seems to me that the verify() will trigger a check to verify that the expect*() calls did actually happen whereas this would not be checked for the match*() ones? Is that correct?" Tim: "Yes, Vincent, that's correct" Thanks for your patience Tim! :-) -Vincent |