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.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arthur Zagretdinov edited this page Apr 21, 2019
·
5 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:
org/powermock/extensions/configuration.properties
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:
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:
powermock.global-ignore="org.myproject.*"
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:
mockito.mock-maker-class=mock-maker-inline
Example of using Mockito mock-maker-inline with PowerMock