Which method is used to create a partial mock in EasyMock?
A) createMockBuilder()
B) partialMock()
C) createPartialMock()
D) mockPartial()
Answer:
A) createMockBuilder()
Explanation:
The createMockBuilder()
method in EasyMock is used to create a partial mock. A partial mock allows you to mock only specific methods of a class while allowing other methods to behave as they would in a real object.
For example:
MyService partialMockService = EasyMock.createMockBuilder(MyService.class)
.addMockedMethod("methodToMock")
.createMock();
In this example, createMockBuilder()
is used to create a partial mock of MyService
, where only the method methodToMock()
is mocked.