My code looks like
Request1 req1 = EasyMock.anyObject(Request1.class);
Request2 req2 = EasyMock.anyObject(Request2.class);
Request3 req3 = EasyMock.anyObject(Request3.class);
@Mock Service service;
// ...
@Test
myTest() {
Response resp = new Response();
EasyMock.expect(service.lookup(req1, req2)).andReturn(resp);
// ...
}
The "EasyMock.expect" line is failing with
2 matchers expected, 3 recorded.
This exception usually occurs when matchers are mixed with raw values when recording a method:
foo(5, eq(6)); // wrong
You need to use no matcher at all or a matcher for every single param:
foo(eq(5), eq(6)); // right
foo(5, 6); // also right
I'm giving two matchers though. Perhaps the problem is that andReturn
is given a value, but of course I am trying to say "return resp
no matter what input is given."
This seems different from the usual cause. FWIW andStubReturn
gives same error (which I woule expect).