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.

Features

  • When writing unit tests it is often useful to bypass encapsulation and therefore PowerMock includes several features that simplifies reflection specifically useful for testing
  • Allows easy access to internal state, but also simplifies partial and private mocking
  • 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
  • PowerMock aims to extend the existing API's with a small number of methods and annotations to enable the extra features
  • Static methods should be avoided completely and so on simply because of the limitations of existing frameworks

Project Samples

Project Activity

See All Activity >

Categories

Frameworks

License

Apache License V2.0

Follow PowerMock

PowerMock Web Site

Other Useful Business Software
Get Avast Free Antivirus | Your top-rated shield against malware and online scams Icon
Get Avast Free Antivirus | Your top-rated shield against malware and online scams

Boost your PC's defense against cyberthreats and web-based scams.

Our antivirus software scans for security and performance issues and helps you to fix them instantly. It also protects you in real time by analyzing unknown files before they reach your desktop PC or laptop — all for free.
Free Download
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of PowerMock!

Additional Project Details

Programming Language

Java

Related Categories

Java Frameworks

Registered

2023-08-01