How do you reset a mock object in EasyMock?

How do you reset a mock object in EasyMock?

A) reset()
B) clear()
C) resetMock()
D) initialize()

Answer:

A) reset()

Explanation:

The reset() method in EasyMock is used to reset a mock object to its initial state. After calling reset(), the mock object no longer has any expectations or recorded interactions, and you can start setting up new expectations from scratch.

For example:


EasyMock.reset(mockService);

In this example, calling reset() on mockService clears all previous interactions and expectations, allowing you to reconfigure the mock object as needed.

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