From: chris c. <drc...@ya...> - 2003-07-01 22:45:48
|
I think there need to be some functional tests for Mock as well as the mocked unit tests. Functional tests are (in this case) better at expressing the intent of the code since they are effectively examples of usage. For instance what is the intended behaviour of the Mock if you setup a match and then call it more than once? How about for OrderedMock? I have to look at the tests for CallSequence and CallBag (in the 0.09 release) to figure this out which means that I have to read the implementation to tell that Mock uses these things and I can't tell from the tests what the intent is, it is easier to read the code. I chose this example because the test is easy if you have setup a mock and proxy public void testMatchAndReturn() throws Throwable { mock.matchAndReturn(METHOD_NOARGANDRETURN_NAME, METHOD_NOARGANDRETURN_RESULT); mock.verify(); for (int i = 0; i < 4; i++) { assertEquals("should get expected result every time:" + i, METHOD_NOARGANDRETURN_RESULT, proxy.noArgMethod()); } mock.verify(); } And it passes on Mock and fails on OrderedMock in both 0.09 versions and Nat's branch. Now I don't know if OrderedMock is supposed to treat matches differently to Mock or not and I really have no way of telling. My feeling is that this is a bug and that the only difference between Mock and OrderedMock should be the way they handle the order of expected calls, in all other ways the behaviour should be identical. Is this right? Chris. |