-
Deprecated Packages
-
Deprecated InterfacesInterfaceDescriptionsince 2.15.4 because this internal class was leaking from the public API. For more information why deprecated, see
InstantiatorProvider2
. UseInstantiator
instead.Provides instances of classes.
- please useMockingDetails.printInvocations()
instead. An instance ofMockingDetails
can be retrieved viaMockito.mockingDetails(Object)
.since 2.15.4 because this internal class was leaking from the public API. For more information why deprecated, seeInstantiatorProvider2
and Issue 1303Mockito 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-INF
directory, Mockito will look inmockito-extensions
directory. The reason for that is that Android SDK strips jar from theMETA-INF
directory when creating an APK.- The implementation itself, for example
org.awesome.mockito.AwesomeInstantiatorProvider
that implements theInstantiatorProvider
. - A file "
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 standardClassLoader.getResource(java.lang.String)
mechanism.So just create a custom implementation of
InstantiatorProvider
and place the qualified name in the following filemockito-extensions/org.mockito.plugins.InstantiatorProvider
.This class is deprecated and was replaced by
InstantiatorProvider2
. Hence if there is both amockito-extensions/org.mockito.plugins.InstantiatorProvider
andmockito-extensions/org.mockito.plugins.InstantiatorProvider2
the second one takes preference. - The implementation itself, for example
-
Deprecated ClassesClassDescriptionUse
ArgumentMatchers
. This class is now deprecated in order to avoid a name clash with Hamcrestorg.hamcrest.Matchers
class. This class will likely be removed in version 4.0.as of 2.1.0. Use theMockitoJUnitRunner
runner instead which contains support for detecting unused stubs.If you still prefer using this runner, tell us why (create ticket in our issue tracker).
Moved toMockitoJUnitRunner
, this class will be removed with Mockito 4Moved toMockitoJUnitRunner.Silent
, this class will be removed with Mockito 4Moved toMockitoJUnitRunner.Strict
, this class will be removed with Mockito 4as of 2.1.0. Use theMockitoJUnitRunner
runner instead which contains support for detecting unused stubs.If you still prefer using this runner, tell us why (create ticket in our issue tracker).
-
Deprecated ExceptionsExceptionsDescriptionsince 2.15.4 because this internal class was leaking from the public API. For information why deprecated, see
InstantiatorProvider2
. UseInstantiator
andInstantiationException
types instead.Exception generated when
Instantiator.newInstance(Class)
failed.
-
Deprecated Errors
-
Deprecated MethodsMethodDescriptionas of 2.1.0 Use the enum-constant directly, instead of this getter. This method will be removed in a future release
E.g. instead ofAnswers.CALLS_REAL_METHODS.get()
useAnswers.CALLS_REAL_METHODS
.With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.This will be removed in Mockito 4.0 This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.as of 2.1.0 useArgumentMatchers.any()
With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.as of 2.1.0 please useBDDMockito.BDDStubber.willDoNothing()
insteadplease useBDDMockito.BDDStubberImpl.willDoNothing()
insteadSince 3.0.1. Please migrate your code toBDDMockito.Then.shouldHaveNoInteractions()
Please use the extension mechanismAnnotationEngine
instead, this method will probably be removed in mockito 4.Not used by Mockito but by mockito-scalaNot used by Mockito but by mockito-scalaNot used by Mockito but by mockito-scala- This internal method leaks internal classInvocationMatcher
. Please useVerificationData.getTarget()
instead. Deprecated since 2.2.12UseInvocationFactory.createInvocation(Object, MockCreationSettings, Method, RealMethodBehavior, Object...)
instead. Why deprecated? We found use cases where we need to handle Throwable and ensure correct stack trace filtering (removing Mockito internals from the stack trace). Hence the introduction ofInvocationFactory.RealMethodBehavior
. Creates instance of anInvocation
object. This method is useful for framework integrators to programmatically simulate method calls on mocks usingMockHandler
. It enables advanced framework integrations.Please useinstead
- please useMockingDetails.printInvocations()
instead. An instance ofMockingDetails
can be retrieved viaMockito.mockingDetails(Object)
.Since 3.0.1. Please migrate your code toMockito.verifyNoInteractions(Object...)
UseMockitoAnnotations.openMocks(Object)
instead. This method is equivalent toopenMocks(testClass).close()
. The close method should however only be called after completed usage oftestClass
. If using static-mocks or customMockMaker
s, using this method might cause misbehavior of mocks injected into the test class.- please useMockingDetails.printInvocations()
instead. An instance ofMockingDetails
can be retrieved viaMockito.mockingDetails(Object)
., seeInstantiatorProvider
. Returns an instantiator, used to create new class instances.
AnnotationEngine
instead, this interface will probably be removed in mockito 4.