All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mockito.plugins.PluginSwitch Maven / Gradle / Ivy

There is a newer version: 5.13.0
Show newest version
package org.mockito.plugins;

import org.mockito.Incubating;

/**
 * Allows switching off the plugins that are discovered on classpath.
 *
 * 

* Mockito will invoke this interface in order to select whether a plugin is enabled or not. *

* *

* When a particular plugin is switched off, the default Mockito behavior is used. * For example, if Android's dexmaker MockMaker is switched off, * Mockito default MockMaker implementation is used {@link org.mockito.plugins.MockMaker} *

* *

Using the extension point

* *

* The plugin mechanism of mockito works in a similar way as the {@link java.util.ServiceLoader}, however instead of * looking in the META-INF directory, Mockito will look in mockito-extensions directory. * The reason for that is that Android SDK strips jar from the META-INF directory when creating an APK. *

* *
    *
  1. The implementation itself, for example org.awesome.mockito.AwesomeMockMaker that extends the MockMaker.
  2. *
  3. A file "mockito-extensions/org.mockito.plugins.MockMaker". The content of this file is * exactly a one line with the qualified name: org.awesome.mockito.AwesomeMockMaker.
  4. *

* *

Note that if several mockito-extensions/org.mockito.plugins.MockMaker files exists in the classpath * Mockito will only use the first returned by the standard {@link ClassLoader#getResource} mechanism. *

* So just create a custom implementation of {@link PluginSwitch} and place the qualified name in the following file * mockito-extensions/org.mockito.plugins.PluginSwitch. *

* * @since 1.10.15 */ @Incubating public interface PluginSwitch { /** * Mockito invokes this method for every plugin found in the classpath * (except from the {@code PluginSwitch} implementation itself). * If no custom plugins are discovered this method is not invoked. * * @since 1.10.15 */ boolean isEnabled(String pluginClassName); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy