Reviews by real users

Just finished a project using open source libraries and have fresh impressions?

Write a review to share your experiences with open source!

On DevRates we focus on reviews by developers using libraries on their daily work.

Technology radar

Launching a start-up or commercial project using open-source libraries? No time to evaluate various technology stacks?

Interested in the latest trends and top-rated open source projects for all layers of your application?

DevRates contains projects reviews of most popular tagged categories and programming languages.

Build your skill profile

Join DevRates and build your public profile from libraries you know and experience positions from projects you've been involved in.

Follow projects and don't miss any news from blogs and twitter on your wall.

Your company is looking for talented developers? Register on DevRates and show your technology stack on your company profile.

JOIN THE COMMUNITY TAKE A TOUR

Powermock

Homepage

http://code.google.com/p/powermock/

Latest release

1.4.12 (05/04/2012)

Developed by

Jayway

Licenses

Apache 2.0

Overall rating

N/A
Usability
N/A
Simplicity
N/A
Documentation
N/A
Community
N/A

Tags

  • unit testing

  • mocking

  • java

Description

Writing unit tests can be hard and sometimes good design has to be sacrificed for the sole purpose of testability. Often testability corresponds to good design, but this is not always the case. For example final classes and methods cannot be used, private methods sometimes need to be protected or unnecessarily moved to a collaborator, static methods should be avoided completely and so on simply because of the limitations of existing frameworks.

PowerMock is a framework that extend other mock libraries such as EasyMock with more powerful capabilities. PowerMock uses a custom classloader and bytecode manipulation to enable mocking of static methods, constructors, final classes and methods, private methods, removal of static initializers and more. By using a custom classloader no changes need to be done to the IDE or continuous integration servers which simplifies adoption. Developers familiar with the supported mock frameworks will find PowerMock easy to use, since the entire expectation API is the same, both for static methods and constructors. PowerMock aims to extend the existing API's with a small number of methods and annotations to enable the extra features. Currently PowerMock supports EasyMock and Mockito.

When writing unit tests it is often useful to bypass encapsulation and therefore PowerMock includes several features that simplifies reflection specifically useful for testing. This allows easy access to internal state, but also simplifies partial and private mocking.

 

Related projects

Latest reviews

9
brunocn80

black magic for your unit tests

full review
Sign in to vote for review score: 0
9
peper

Very easy to use. Works great with Mockito. Of course when you need to use Powermock for testing (e.g. constructor mocking or static initializer suppresion) you should rethink your design because it is probably bad. However Powermock is still a lifesaver for testing legacy code.

full review
Sign in to vote for review score: 0
Loading reviews...
Please sign in to rate or post a comment
Scroll to top