How do you ignore unexpected method calls in EasyMock?
A) niceMock()
B) ignoreUnexpected()
C) expectNothing()
D) andIgnore()
Answer:
A) niceMock()
Explanation:
The niceMock()
method in EasyMock is used to create a mock object that ignores unexpected method calls. Unlike a regular mock, a nice mock does not throw an exception if a method is called without an expectation being set.
For example:
MyService niceMockService = EasyMock.niceMock(MyService.class);
In this example, niceMock()
creates a mock of MyService
that will ignore any unexpected method calls during the test.