The road so far….

July 10, 2010

Easymock, Assert arguments of method call

Filed under: java — Tags: — Rahul Sharma @ 8:41 pm

EasyMock is used for mocking classes, interfaces and corresponding method calls. When you mock a method call you would like to assert the arguments of the call. Asserting an argument can be in terms of identical arguments – as provided during mock, similar arguments – similarity in terms of class/fields/order etc, or any other kind of assertion possible. The package provides whole bunch of options to assert the same. Here I have listed down a couple of them that can be used under varied situations. (more…)

May 13, 2010

EasyMock expectation(EasyMock.expect) flavours explained

Filed under: java — Tags: , — Rahul Sharma @ 10:29 pm

The EasyMock¬† framework for unit testing is quite powerful and has loads of mocking APIs for all purposes. One of the most important APIs for mocking is the createMock API. Using this we can create mock objects for a specified interface and then record and verify the method calls. Events are recorded in the IExpectationSetters, which can be created by the EasyMock.expect API. After creating the IExpectationSetters we can set the returned result/calling behavior using the different options available. (more…)