PowerMock Configuration

Arthur Zagretdinov edited this page Aug 13, 2017 · 4 revisions

PowerMock Configuration

   Feature avaliable since PowerMock 1.7.0

As of version of 1.7.0 it's possible to globally configure PowerMock. This configuration is applied to all test classes that in the classpath. You may enable the configuration by creating by adding this file to the classpath:


Global @PowerMockIgnore

By default PowerMock loads all classes with its MockClassLoader. The classloader loads and modified all classes except:

  • system classes. They are deferred to system classloader
  • classes located in packages that are specified as ignored.

Before 1.7.0 the only one way to ignore a package was to use the @PowerMockIgnore annotation:

 public class MyTest {

In some cases the only way to avoid certain classloading related issues is to use @PowerMockIgnore and this used to imply that @PowerMockIgnore was copied and pasted in many tests.

But since PowerMock 1.7.0 you can specify packages to ignore using the configuration file:


Multiple packages/classes can be specified using comma:


Example of using PowerMock Configuration for global @PowerMockIgnore.

Mockito mock-maker-inline

PowerMock can delegate calls to another MockMaker, these tests are run without PowerMock. This can be configured by adding the following property to configuration file:


Example of using Mockito mock-maker-inline with PowerMock

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.