PowerMock icon
PowerMock icon

PowerMock

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...

Cost / License

  • Free
  • Open Source

Platforms

  • Mac  Java
  • Windows  Java
  • Linux  Java
  • Java
-
No reviews
0likes
0comments
0news articles

Features

Suggest and vote on features
No features, maybe you want to suggest one?

 Tags

PowerMock News & Activities

Highlights All activities

Recent activities

No activities found.

PowerMock information

  • Developed by

    Arthur Zagretdinov
  • Licensing

    Open Source (Apache-2.0) and Free product.
  • Written in

  • Alternatives

    2 alternatives listed
  • Supported Languages

    • English

GitHub repository

  •  4,193 Stars
  •  583 Forks
  •  463 Open Issues
  •   Updated  
View on GitHub

Popular alternatives

View all
PowerMock was added to AlternativeTo by André Peixoto on and this page was last updated .
No comments or reviews, maybe you want to be first?
Post comment/review

What is PowerMock?

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 extends 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.

Please note that PowerMock is mainly intended for people with expert knowledge in unit testing. Putting it in the hands of junior developers may cause more harm than good.

Official Links