InstantiatorProvider2 and
Issue 1303
Mockito will invoke this interface in order to fetch an instance instantiator provider.
By default, an internal byte-buddy/asm/objenesis based implementation is used.
The plugin mechanism of mockito works in a similar way as the
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.
org.awesome.mockito.AwesomeInstantiatorProvider that implements the
InstantiatorProvider.mockito-extensions/org.mockito.plugins.InstantiatorProvider".
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.InstantiatorProvider
files exists in the classpath, Mockito will only use the first returned by the standard
ClassLoader.getResource(java.lang.String) mechanism.
So just create a custom implementation of InstantiatorProvider and place the
qualified name in the following file
mockito-extensions/org.mockito.plugins.InstantiatorProvider.
This class is deprecated and was replaced by
InstantiatorProvider2. Hence if there is both a
mockito-extensions/org.mockito.plugins.InstantiatorProvider and
mockito-extensions/org.mockito.plugins.InstantiatorProvider2 the second one
takes preference.
@Deprecated public interface InstantiatorProvider
| Modifier and Type | Method and Description |
|---|---|
org.mockito.internal.creation.instance.Instantiator |
getInstantiator(MockCreationSettings<?> settings)
Deprecated.
|
@Deprecated org.mockito.internal.creation.instance.Instantiator getInstantiator(MockCreationSettings<?> settings)