What is the purpose of the replay() method in EasyMock?
A) To switch the mock object from record mode to replay mode
B) To verify that all expectations were met
C) To reset the mock object
D) To create a new mock object
Answer:
A) To switch the mock object from record mode to replay mode
Explanation:
The replay()
method in EasyMock is used to switch the mock object from record mode to replay mode. After calling replay()
, the mock object will start returning the results that were defined during the expectation setup phase.
For example:
EasyMock.replay(mockService);
In this example, calling replay()
on mockService
switches it to replay mode, meaning it will now behave according to the expectations set up earlier.