Which method is used to create a partial mock in EasyMock?

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.

Reference links:

https://www.javaguides.net/p/top-java-libraries.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top