In the API doc it is mentioned that in the strictmock order checking is enabled by default while in case of nice mock it is not . I did not get what exactly they meant by "order checking".
createNiceMock() creates a mock and sets the default implementation of each method of the mock. If EasyMock. createMock() is used, then invoking the mock method throws assertion error.
The expect() method tells EasyMock to simulate a method with certain arguments. The andReturn() method defines the return value of this method for the specified method parameters. The times() method defines how often the Mock object will be called. The replay() method is called to make the Mock object available.
Benefits of EasyMockNo Handwriting − No need to write mock objects on your own. Refactoring Safe − Renaming interface method names or reordering parameters will not break the test code as Mocks are created at runtime. Return value support − Supports return values. Exception support − Supports exceptions.
If you tell a mock to expect a call to foo()
, then to expect a call to bar()
, and the actual calls are bar()
then foo()
, a strict mock will complain but a nice mock won't. That's what order checking means.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With