Interface InstantiatorProvider2
-
public interface InstantiatorProvider2Mockito will invoke this interface in order to fetch an instance instantiator provider.
By default, an internal byte-buddy/asm/objenesis based implementation is used.
Using 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.AwesomeInstantiatorProvider2that implements theInstantiatorProvider2. - A file "
mockito-extensions/org.mockito.plugins.InstantiatorProvider2". The content of this file is exactly a one line with the qualified name:org.awesome.mockito.AwesomeInstantiatorProvider.
Note that if several
mockito-extensions/org.mockito.plugins.InstantiatorProvider2files 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
InstantiatorProvider2and place the qualified name in the following filemockito-extensions/org.mockito.plugins.InstantiatorProvider2.- Since:
- 2.15.4
- The implementation itself, for example
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InstantiatorgetInstantiator(MockCreationSettings<?> settings)Returns an instantiator, used to create new class instances.
-
-
-
Method Detail
-
getInstantiator
Instantiator getInstantiator(MockCreationSettings<?> settings)
Returns an instantiator, used to create new class instances.- Since:
- 2.15.4
-
-