Wednesday, November 24, 2010

Capturing the parameters passed to expected methodof your mock item

We all use easymock to mock java objects to speed up developing our unit tests and focus on the code fragment.

I would like to point out a great feature of this framework which is not known very much. You need to be familiar with easymock already to get the point.

You can capture the object that is passed to your expectation. Please see the code below with comments.


As you might already noticed above, you can easily get the passed object from capturer object. Capturer object was used with static method "capture" of easymock.

No comments:

Post a Comment