I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Thursday 22 April 2010

Mock Frameworks

In this entry, I present a summary of the features of mock frameworks. In particular, I looked at two different mock frameworks: easyMock (MIT Licence), Mockito (Apache Licence) and JMock (probably equivalent to BSD, MIT or Apache but I am not completely sure). The Mockito framework seems to be trying to extend even more the features of the easy mock.

Usual Use Cases of Mock Objects

I adapted the following list from a wikipedia entry. It shows the cases where it a good practice to use mocks.

  • results of method do not follow a very deterministic pattern
  • The mock can simulate a complex object or an object difficult to obtain, e.g a given state in a GUI
  • A state of a system which is expensive to create, resource, processing, power...
  • The object has not yet been provided, perhaps by an other team

Here are some useful posts on mocks:

I notice this post is not at all too clean. It needs to explain the purpose of spying and the difference there is with mock objects which are only dummy object or fake object.