PowerMock

PowerMock can be used to test code normally regarded as untestable! Have you ever heard anyone say that you should never use static or final methods in your code because it makes them impossible to test? Have you ever changed a method from private to protected for the sake of testability? What about avoiding “new”? Think again! PowerMock lets you mock static methods, remove static initializers, allow mocking without dependency injection and much much more. And it works just as well for J2EE as J2ME! This presentation will give the audience a good understanding on how to easily unit-test your code without the limitations of the common mock frameworks such as EasyMock and JMock.

One comment

  1. No flame intended, but this is one of the worst ideas ever. Apart from subclassing finals which can be useful, mocking static entities is *global mutable state* which means renouncing to all the benefits unit testing would do to your code (for instance: a good
    Api).

Comments are closed.