JSF & Java Blog

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

Posts Tagged / PowerMock

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

Cobertura code coverage with Maven and PowerMock

If you use Powermock for unit testing with Maven and Cobertura for code coverage, you are likely to be affected by the following issue noted on the PowerMock issue tracker. If you did not have the maven-surefire-plugin forkmode configured to ‘pertest’, you would find that any tests annotated with @RunWith(PowerMockRunner.class) had zero percentage code coverage […]

3