Jens Nordahl

EasyMock: Capturing arguments from multiple calls

With EasyMock it is, in some cases, difficult to set up sufficiently precise expectations for the mocks. This may be because we don’t know in advance with which arguments they get called or how often they get called. Or because the verification, we have to make in the test, involves relating the calls to one mock object to the calls to another mock object or relating calls to mock objects to data returned from the object being tested.

In such cases the solution may be to capture “traces” of the method calls to the mock objects, and then, after having exercised the object being tested, to make the needed verifications using the captured traces.