Log calls to mocked methods with Easymock

105 Views Asked by At

Is it possible to log all calls to mocked methods, and preferably from where it was called? (Without spending a lot of time on some own implementation.) That would sometimes be very helpful for debugging.

(And yes, my need for it probably indicates that the code are too complex and the test covers too much functionality. But sometimes you have to live with bad code.)

1

There are 1 best solutions below

0
Henri On

With EasyMock it's quite easy. Anything not recorded will throw an exception from where it is called.

If you want to log any calls, you do not need a mock for that. Just a basic proxy will do it. I can give code example if needed.