-
Deprecated Packages
-
Deprecated InterfacesInterfaceDescriptionsince 2.15.4 because this internal class was leaking from the public API. For more information why deprecated, see
InstantiatorProvider2. UseInstantiatorinstead.Provides instances of classes.
- please useMockingDetails.printInvocations()instead. An instance ofMockingDetailscan be retrieved viaMockito.mockingDetails(Object).since 2.15.4 because this internal class was leaking from the public API. For more information why deprecated, seeInstantiatorProvider2and 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-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.AwesomeInstantiatorProviderthat 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.InstantiatorProviderfiles 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
InstantiatorProviderand 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.InstantiatorProviderandmockito-extensions/org.mockito.plugins.InstantiatorProvider2the 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.Matchersclass. This class will likely be removed in version 4.0.as of 2.1.0. Use theMockitoJUnitRunnerrunner 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 theMockitoJUnitRunnerrunner 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. UseInstantiatorandInstantiationExceptiontypes 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 mechanismAnnotationEngineinstead, 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 anInvocationobject. 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 ofMockingDetailscan 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 customMockMakers, using this method might cause misbehavior of mocks injected into the test class.- please useMockingDetails.printInvocations()instead. An instance ofMockingDetailscan be retrieved viaMockito.mockingDetails(Object)., seeInstantiatorProvider. Returns an instantiator, used to create new class instances.
AnnotationEngineinstead, this interface will probably be removed in mockito 4.