How can I mock a method in easymock that shall return one of its parameters?
Well, the easiest way would be to just use the Capture in the IAnswer implementation… when doing this inline you have to declare it final of course. MyService mock = createMock(MyService.class); final Capture<ParamAndReturnType> myCapture = new Capture<ParamAndReturnType>(); expect(mock.someMethod(capture(myCapture))).andAnswer( new IAnswer<ParamAndReturnType>() { @Override public ParamAndReturnType answer() throws Throwable { return myCapture.getValue(); } } ); replay(mock) This … Read more