-
Interfaces Interface Description org.mockito.exceptions.PrintableInvocation org.mockito.ReturnValues Instead, please useAnswer
interfaceIn rare cases your code might not compile with recent deprecation & changes. Very sorry for inconvenience but it had to be done in order to keep framework consistent.
Why it is deprecated? ReturnValues is being replaced by Answer for better consistency & interoperability of the framework. Answer interface has been in Mockito for a while and it has the same responsibility as ReturnValues. There's no point in mainting exactly the same interfaces.
Configures return values for an unstubbed invocation
Can be used in
Mockito.mock(Class, ReturnValues)
-
Classes Class Description org.mockito.BDDMockito.BDDOngoingStubbingImpl not part of the public API, useBDDMockito.BDDMyOngoingStubbing
instead.org.mockito.BDDMockito.BDDStubberImpl not part of the public API, useBDDMockito.BDDStubber
instead.org.mockito.exceptions.Discrepancy org.mockito.exceptions.Pluralizer org.mockito.exceptions.verification.junit.JUnitTool org.mockito.junit.MockitoJUnitRule org.mockito.runners.MockitoJUnit44Runner org.mockito.stubbing.answers.ReturnsElementsOf
-
Enums Enum Description org.mockito.internal.stubbing.defaultanswers.Answers
-
Annotation Types Annotation Type Description org.mockito.MockitoAnnotations.Mock
-
Methods Method Description org.mockito.configuration.AnnotationEngine.createMockFor(Annotation, Field) Please useAnnotationEngine.process(Class, Object)
method instead that is more robustCreates mock, ArgumentCaptor or wraps field instance in spy object. Only if of correct annotation type.
org.mockito.configuration.DefaultMockitoConfiguration.getReturnValues() org.mockito.configuration.IMockitoConfiguration.getReturnValues() Please useIMockitoConfiguration.getDefaultAnswer()
Steps:
1. Leave the implementation of getReturnValues() method empty - it's not going to be used anyway.
2. Implement getDefaultAnswer() instead.
In rare cases your code might not compile with recent deprecation & changes. Very sorry for inconvenience but it had to be done in order to keep framework consistent.
See javadoc
ReturnValues
for info why this method was deprecatedAllows configuring the default return values of unstubbed invocations
See javadoc for
IMockitoConfiguration
org.mockito.internal.configuration.InjectingAnnotationEngine.createMockFor(Annotation, Field) org.mockito.Mockito.mock(Class<T>, ReturnValues) Please use mock(Foo.class, defaultAnswer);org.mockito.Mockito.stubVoid(T) UseMockito.doThrow(Throwable)
method for stubbing voidsorg.mockito.verification.VerificationWithTimeout.atMost(int) Deprecated Validation with timeout combined with never simply does not make sense, as atMost() will typically immediately pass, and therefore not wait the timeout. The behaviour you may be looking for is actually provided by after().atMost().To avoid compilation errors upon upgrade the method is deprecated and it throws a "friendly reminder" exception.
In a future release we will remove timeout(x).atMost(y) and timeout(x).never() from the API.
Do you want to find out more? See issue 235
org.mockito.verification.VerificationWithTimeout.never() Validation with timeout combined with never simply does not make sense, as never() will typically immediately pass, and therefore not wait the timeout. The behaviour you may be looking for is actually provided by after().never().To avoid compilation errors upon upgrade the method is deprecated and it throws a "friendly reminder" exception.
In a future release we will remove timeout(x).atMost(y) and timeout(x).never() from the API.
Do you want to find out more? See issue 235
-
Constructors Constructor Description org.mockito.ArgumentCaptor() Please use factory methodArgumentCaptor.forClass(Class)
to create captorsThis is required to avoid NullPointerExceptions when autoUnboxing primitive types. See issue 99.
Example:
ArgumentCaptor<Person> argument = ArgumentCaptor.forClass(Person.class); verify(mock).doSomething(argument.capture()); assertEquals("John", argument.getValue().getName());
org.mockito.junit.MockitoJUnitRule() org.mockito.stubbing.answers.ReturnsElementsOf(Collection<?>)