The EasyMock framework (mocks for Java) has very clever method createNiceMock, it is:
Creates a mock object that implements the given interface, order checking is disabled by default, and the mock object will return 0, null or false for unexpected invocations.
I wonder about some equivalent method in Rhino Mocks framework that can mocks with 0, null or false for unexpected invocations (I am not interesting in order checking but if it will be it will OK too)
Those are characteristics of dynamic mock:
In earlier versions of you had to explicitly create one:
Nowadays, by default mocks are assumed to be dynamic mocks as long as you create them with
MockRepository.GenerateMock<T>()method. Expectations call order is also irrelevant. Assuming we got expectations set up as below:Tested code like the example below
won’t cause the test to fail. Order doesn’t matter, unexpected invocations are ignored and return default values.