EasyMock 1.2 Wrapper

Table of Contents
Popular Tags
Twitter Updates
Random Pictures

What is EasyMock Wrapper

This is a wrapper for EasyMock 1.x MockControl / EasyMock Class Extension 1.x.

The purpose is to mimic the fluent interface of EasyMock 2.x (get rid of Controls) while actually using libraries compatible with Java 1.3. As the helper doesn't extend EasyMock, the functionality offered is limited to version 1.x API, however it is accessed in a 2.x style.

Benefits of EasyMock Wrapper

Fluent EasyMock 2.x style API with Java 1.4

No need to manage MockControls in your test

Easy to migrate to EasyMock 2.x if Java 1.5+ becomes possible for you

Just need to change imports. If you use methods that are not in EasyMock 2 like one of the xxxAll then of course you need some refactoring.

Mocks interfaces/classes in uniform way

No need to use MockClassControl for mocking classes

Nice  resetAll, replayAll, verifyAll convenience methods

How to use

If you are already using EasyMock then you just need the easymock-wrapper.jar.
Otherwise download the ZIP package which includes easymock-wrapper.jar and all EasyMock dependencies.

Sample code:

// MockControl is created automatically and stored internally
Sample mock = (Sample) EasyMock.createMock(Sample.class);
// Chain various andReturn(), andThrow() and times() methods to specify changing behavior
EasyMock.expect(mock.isOk()).andReturn(true).times(2).andReturn(false);

// Helper will issue replay on the MockControl corresponding to the given mock
EasyMock.replayAll();
// your test code
...

EasyMock.verifyAll();

Download

  Name Size Creator (Last Modifier) Creation Date Last Mod Date Comment  
ZIP Archive easymock-wrapper-0.8.zip 377 kb Ürgo Ringo Aug 04, 2008 Aug 04, 2008 Full package
Java Source easymock-wrapper.jar 7 kb Ürgo Ringo Aug 04, 2008 Aug 04, 2008 Jar

Labels