Interface PluginSwitch
-
public interface PluginSwitchAllows 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
MockMakerUsing the extension point
The plugin mechanism of mockito works in a similar way as the
ServiceLoader, however instead of looking in theMETA-INFdirectory, Mockito will look inmockito-extensionsdirectory. The reason for that is that Android SDK strips jar from theMETA-INFdirectory when creating an APK.- The implementation itself, for example
org.awesome.mockito.AwesomeMockMakerthat extends theMockMaker. - 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.
Note that if several
mockito-extensions/org.mockito.plugins.MockMakerfiles exists in the classpath Mockito will only use the first returned by the standardClassLoader.getResource(java.lang.String)mechanism.So just create a custom implementation of
PluginSwitchand place the qualified name in the following filemockito-extensions/org.mockito.plugins.PluginSwitch.- Since:
- 1.10.15
- The implementation itself, for example
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanisEnabled(String pluginClassName)Mockito invokes this method for every plugin found in the classpath (except from thePluginSwitchimplementation itself).
-
-
-
Method Detail
-
isEnabled
boolean isEnabled(String pluginClassName)
Mockito invokes this method for every plugin found in the classpath (except from thePluginSwitchimplementation itself). If no custom plugins are discovered this method is not invoked.- Since:
- 1.10.15
-
-