From: Nat P. <nat...@b1...> - 2003-08-26 21:38:44
|
If you want to mock the behaviour of a *sequence* of calls to a Mock you should have used an OrderedMock (or a CallSequence that you add to a normal Mock), in both v0.09 and the current CVS version. The fact that your tests passed in 0.09 sounds like a lucky outcome of the internal implementation rather than documented/tested behaviour of the API itself. Warning: don't rely on the current CVS version being stable. The dynamic API is still being worked out by the mockobjects team. Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "Francois Beausoleil" <fb...@us...> To: <moc...@li...> Sent: Tuesday, August 26, 2003 10:10 PM Subject: [MO-java-dev] expectAndReturn does not behave the same as in 0.09 ? Hi, Here's my test implementation: private final Mock mockNewsIterator = new Mock(Iterator.class); private final Iterator newsIterator = (Iterator) mockNewsIterator.proxy(); public void testInstructsTheCallerToPrintTheBodyAgainWhenMoreItemsRemain() throws JspException { mockNewsIterator.expectAndReturn("hasNext", C.NO_ARGS, Boolean.TRUE); mockNewsIterator.expectAndReturn("next", C.NO_ARGS, new NewsItem()); mockNewsIterator.expectAndReturn("hasNext", C.NO_ARGS, Boolean.FALSE); assertEquals(TagSupport.EVAL_BODY_AGAIN, tag.doAfterBody()); assertEquals(TagSupport.SKIP_BODY, tag.doAfterBody()); mockNewsIterator.verify(); } When I had 0.09 installed, this test was not failing. Now, I have 0.10dev (CVS pserver as of 2003/08/26 ~ 15:30), and the test fails. Does this mean that I should switch to using OrderedMock for such tests ? What I am trying to achieve here is to have the mockIterator return true once, and false once. If it is called any more times, it should fail. In the mean time, there should be one call to the next() method. Thanks, François Developer of Java Gui Builder http://jgb.sourceforge.net/ ------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0 _______________________________________________ Mockobjects-java-dev mailing list Moc...@li... https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev |