Skip to main content

Posts

Showing posts from December, 2009

Introducing EasyMock

This blog will share my understanding about EasyMock, before moving forward to EasyMock first want to tell you about what is Mock and what is Mock Object and there purpose.One of the web definition of Mock is “An intimation of counterfeit”. If we apply definition of mock to mock objects, mock objects are just an intimation or counterfeit of objects. Now we have to look where these mock objects are applied in real world.Consider a use case where we have a UserService that performs some business operation on a User entity and then persists user entity using UserDao(Persistence Service). When we write test case for UserService, unintentionally we will be testing UserDao also and we have to take care of successful execution of UserDao also. In such cases Mock Objects comes into picture, we create a mock object of UserDao and provide this mock object to UserService. UserDao mock object will intimate as UserDao and will behave as required.In coming sections I'll be taking this use case …