How do you set up an expectation in EasyMock?
A) expect()
B) setExpectation()
C) expectCall()
D) withExpectation()
Answer:
A) expect()
Explanation:
The expect()
method in EasyMock is used to set up an expectation on a mock object. This method specifies how the mock object should behave when a certain method is called.
For example:
EasyMock.expect(mockService.someMethod()).andReturn(someValue);
In this example, expect()
is used to set up an expectation that when the method someMethod()
is called on mockService
, it will return someValue
.