Question

Having previous experience with RhinoMocks, which distinguishes between two separate Mockery type of classes: one being strict, that performs checks exactly like standard JMock mockery, and normla one, which simply does not care about the methods that you don't list in your expectations.

For instance, if you want to test whether method a() is called on your object, but the whole program might subsequently invoke many other methods, in JMock you have to list everything explicitly, while Rhino would only care that the ones you actually list are called. Is there perhaps a way to achieve the same behaviour in JMock?

Was it helpful?

Solution

but the whole program might subsequently invoke many other methods

Whenever I feel the need for more 'features' in JMock I usually find I have a design problem. Have you considered the need to call many different methods on the same object? Could you refactor to where the behaviour you're testing involves only a few calls to the mock?

You can use allowing(mockedInterface) to allow all calls on a mock.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top