From: Steve F. <st...@m3...> - 2003-07-02 22:14:00
|
We argued this one out and thought that in most case people either care about the order or they don't. I'm not so keen on the newSequence() because it doesn't make clear what happens to expectations applied to the originating Mock. At least the OrderedMock has only one visible behaviour. We also considered adding something like: listener.expectVoid( "first", C.before("second") ); S. Nat Pryce wrote: > Thinking about this, perhaps the whole idea of an OrderedMock is wrong. It > seems that there are no cases where *all* method calls will happen in one > order. Testing explicitly ordered calls is pretty rare, rare enough that > having to write an extra line of code to create a CallSequence to specify > the expected sequence of calls is not really a big problem. > > E.g. instead of: > > OrderedMock listener = new OrderedMock(EventListener.class); > listener.expectVoid( "firstEvent", C.eq(firstEvent) ); > listener.expectVoid( "secondEvent", C.eq(secondEvent) ); > listener.expectVoid( "thirdEvent", C.eq(thirdEvent) ); > > A test would look like: > > Mock listener = new Mock(EventListener.class); > CallCollectionBuilder eventSequence = listener.newSequence(); > eventSequence.expectVoid( "firstEvent", C.eq(firstEvent) ); > eventSequence.expectVoid( "secondEvent", C.eq(secondEvent) ); > eventSequence.expectVoid( "thirdEvent", C.eq(thirdEvent) ); > > I can live with that. I even think that it makes the test more readable. > > Regards, > Nat. > _______________________ > Dr. Nathaniel Pryce > B13media Ltd. > http://www.b13media.com > +44 (0)7712 526 661 > |