Partial mocking an object for unit testing
easymock, java, unit-testing
Solution
You can pass in the parameter types to distinguish between overloaded methods, e.g.
PortalServiceEJB partialMockServiceEJB = EasyMock
.createMockBuilder(ServiceEJB.class)
.addMockedMethod("getStatusType", int.class)
.createMock();
BTW, this is not a partial mock because there is no real object that is being partially mocked out here. Also, you may want to consider Mockito as a mocking framework, the syntax is much nicer IMO.
Problem
I am using easymock for unit testing. I am trying to mock a method inside the test class. ``` ServiceEJB partialMockServiceEJB = EasyMock .createMockBuilder(ServiceEJB.class) .addMockedMethod("getStatusType") .createMock(); ``` But it throws an error : multiple methods with the same name. I have overridden this method with different number of arguments. How can I show which of these overridden methods I want? How can I apply arguments here. Thanks.