Which method is used to verify that all expected interactions with a mock object occurred?
A) verify()
B) check()
C) confirm()
D) validate()
Answer:
A) verify()
Explanation:
The verify()
method in EasyMock is used to verify that all expected interactions with a mock object occurred. This method checks whether all methods that were expected to be called on the mock object were actually called.
For example:
EasyMock.verify(mockService);
In this example, calling verify()
on mockService
ensures that all expected interactions with this mock object took place during the test.