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

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

A) createMock()
B) mock()
C) newMock()
D) generateMock()

Answer:

A) createMock()

Explanation:

The createMock() method in EasyMock is used to create a mock object of a specific class or interface. This mock object can then be used in your tests to simulate the behavior of the real object.

For example:


MyService mockService = EasyMock.createMock(MyService.class);

In this example, createMock() creates a mock object of the MyService interface.

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