Class MockClassLoaderConfiguration

java.lang.Object
org.powermock.core.classloader.MockClassLoaderConfiguration

public class MockClassLoaderConfiguration extends Object
The instance of the class provides information about classes which have to be mocked, loaded without modification or defer to system class loader.
  • Constructor Details

    • MockClassLoaderConfiguration

      public MockClassLoaderConfiguration()
      Create an instance of configuration without any classes to mock or ignore.
    • MockClassLoaderConfiguration

      public MockClassLoaderConfiguration(String[] classesToMock, String[] packagesToDefer)
      Create an instance of configuration
      Parameters:
      classesToMock - classes that should be modified by MockClassLoader.
      packagesToDefer - classes/packages that should be deferred to system class loader.
  • Method Details

    • addIgnorePackage

      public void addIgnorePackage(String... packagesToIgnore)
      Add packages or classes to ignore. Loading of all classes that locate in the added packages will be delegate to a system classloader.

      Package should be specified with using mask. Example:

          configuration.addIgnorePackage("org.powermock.example.*");
      
      Parameters:
      packagesToIgnore - fully qualified names of classes or names of packages that end by .*
    • addClassesToModify

      public final void addClassesToModify(String... classes)
      Add classes that will be loaded by the mock classloader, i.e. these classes will be byte-code manipulated to allow for testing. Any classes contained in the PACKAGES_TO_BE_DEFERRED will be ignored. How ever classes added here have precedence over additionally deferred (ignored) packages (those ignored by the user using @PrepareForTest).
      Parameters:
      classes - The fully qualified name of the classes that will be appended to the list of classes that will be byte-code modified to enable testability.