JSF & Java Blog

Discussion on Java and JSF, including Spring, Maven, Eclipse and Jenkins

Posts Tagged / EasyMock

Mocking Statics and IllegalStateException: no last call on a mock available

If you use PowerMock to mock a static object e.g. and encounter the following error: Check that you have prepared the Class for test using the @PrepareForTest annotation. e.g. An excellent article discussing mocking statics by one of the PowerMock developers can be found here: http://blog.jayway.com/2009/05/17/mocking-static-methods-in-java-system-classes/ Note that you also need to @PrepareForTest any classes […]

1

Chaining EasyMock’s expectation return values

Recently I discovered quite a handy feature of EasyMock’s IExpectationSetters andReturn method. You are able to chain the return values so that you can return different values each time that expectation is called. Chaining Easymock’s expectation return values becomes useful if you consider the following method, where Voucher is an object that cannot be instantiated […]

0