Friday, October 21, 2011
Thursday, October 20, 2011
EasyMock: Capture passed in values
I was writing a unit test this morning where the void method I was testing created an instance of a objected and passed it into a subsequent method. I needed to capture that object so that I could verify that it was set up properly. EasyMock provides a way to do this.
http://blog.jayway.com/2009/03/25/easymock-capturing-arguments-from-multiple-calls/
example:
Capture captured = new Captured();
expect(serviceInstance.method(EasyMock.capture(captured)).andReturn(/* whatever */);
MyObject obj = captured.getValue();
//run unit tests on obj
http://blog.jayway.com/2009/03/25/easymock-capturing-arguments-from-multiple-calls/
example:
Capture
expect(serviceInstance.method(EasyMock.capture(captured)).andReturn(/* whatever */);
MyObject obj = captured.getValue();
//run unit tests on obj
Subscribe to:
Posts (Atom)