|
||||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||
Matchers for general info about matchers.InjectMocks
Answers
WARNING Those answers no longer are used by the framework!!! Please use Answers
See Mockito for more information.
null.
boolean, Boolean or null.
byte, Byte or null.
char, Character or null.
Collection or null.
Matchers.anyCollection().
double, Double or null.
float, Float or null.
null.
List or null.
Matchers.anyList().
long, Long or null.
Map or null.
Matchers.anyMap().
Object or null.
Set or null.
Matchers.anySet().
short, Short or null.
String or null.
ArgumentCaptor.forClass(Class) to create captors
This 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());
VerificationWithTimeout
VerificationWithTimeout
VerificationWithTimeout
To avoid compilation erros upon upgrade the method is deprecated and it throws a "friendly reminder" exception.
In future release we will remove timeout(x).atMost(y) from the API.
Do you want to find out more? See issue 235
OngoingStubbingStubberBoolean argument matchers.
Byte argument matchers.
Answer to be used with Mockito.mock(Class, Answer)
ArgumentCaptor creation on fields.ArgumentCaptor a field annotated by @Captor.Character argument matchers.
BlockJUnit4ClassRunner.String argument that contains the given substring.
MockMaker this method should:
Create a proxy object that implements settings.typeToMock and potentially also settings.extraInterfaces.
You may use the information from settings to create/configure your proxy object.
Your proxy object should carry the handler with it.
AnnotationEngine.process(Class, Object) method instead that is more robust
Creates mock, ArgumentCaptor or wraps field instance in spy object. Only if of correct annotation type.
Mock or @Captor.MockitoAnnotationsdoAnswer() when you want to stub a void method with generic Answer.
Mockito.doAnswer(Answer) style:
doAnswer(answerOne).
- doCallRealMethod() -
Method in class org.mockito.internal.stubbing.StubberImpl
-
- doCallRealMethod() -
Static method in class org.mockito.Mockito
- Use
doCallRealMethod() when you want to call the real implementation of a method.
- doCallRealMethod() -
Method in interface org.mockito.stubbing.Stubber
- Use it for stubbing consecutive calls in
Mockito.doCallRealMethod() style.
- DoesNothing - Class in org.mockito.internal.stubbing.answers
-
- DoesNothing() -
Constructor for class org.mockito.internal.stubbing.answers.DoesNothing
-
- doNothing() -
Method in class org.mockito.internal.stubbing.StubberImpl
-
- doNothing() -
Static method in class org.mockito.Mockito
- Use
doNothing() for setting void methods to do nothing.
- doNothing() -
Method in interface org.mockito.stubbing.Stubber
- Use it for stubbing consecutive calls in
Mockito.doNothing() style:
doNothing().
- doReturn(Object) -
Method in class org.mockito.internal.stubbing.StubberImpl
-
- doReturn(Object) -
Static method in class org.mockito.Mockito
- Use
doReturn() in those rare occasions when you cannot use Mockito.when(Object).
- doReturn(Object) -
Method in interface org.mockito.stubbing.Stubber
- Use it for stubbing consecutive calls in
Mockito.doReturn(Object) style.
- doThrow(Throwable) -
Method in class org.mockito.internal.stubbing.StubberImpl
-
- doThrow(Class<? extends Throwable>) -
Method in class org.mockito.internal.stubbing.StubberImpl
-
- doThrow(Throwable) -
Static method in class org.mockito.Mockito
- Use
doThrow() when you want to stub the void method with an exception.
- doThrow(Class<? extends Throwable>) -
Static method in class org.mockito.Mockito
- Use
doThrow() when you want to stub the void method to throw exception of specified class.
- doThrow(Throwable) -
Method in interface org.mockito.stubbing.Stubber
- Use it for stubbing consecutive calls in
Mockito.doThrow(Throwable) style:
doThrow(new RuntimeException("one")).
- doThrow(Class<? extends Throwable>) -
Method in interface org.mockito.stubbing.Stubber
- Use it for stubbing consecutive calls in
Mockito.doThrow(Class) style:
doThrow(RuntimeException.class).
- doubleThat(Matcher<Double>) -
Static method in class org.mockito.Matchers
- Allows creating custom
Double argument matchers.
String argument that ends with the given suffix.
boolean argument that is equal to the given value.
byte argument that is equal to the given value.
char argument that is equal to the given value.
double argument that is equal to the given value.
float argument that is equal to the given value.
int argument that is equal to the given value.
long argument that is equal to the given value.
short argument that is equal to the given value.
OngoingInjecter that do nothing if a candidate couldn't be found
an OngoingInjecter that will try to inject the candidate trying first the property setter then if not possible try the field access
Float argument matchers.
ArgumentCaptor.
MockSettings.defaultAnswer(org.mockito.stubbing.Answer).
mock.
DescribedInvocation type.
MockSettings.invocationListeners(org.mockito.listeners.InvocationListener...).
OngoingStubbing.getMock()
MockSettings.name(java.lang.String).
InvocationOnMock.getArguments() returns
arguments already processed (e.g.
IMockitoConfiguration.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 deprecated
Allows configuring the default return values of unstubbed invocations
See javadoc for IMockitoConfiguration
Stubber.when(Object)
Mockito.when(Object)
Mock, @Spy, @Captor, @InjectMocks
MockitoAnnotationsInOrder object that allows verifying mocks in order.
Integer argument matchers.
Object argument that implements the given class.
null argument.
null argument, not necessary of the given class.
null argument.
null argument.
MockSettings.serializable().
Field instance.
Long argument matchers.
Mockito.verifyNoMoreInteractions(Object...)
String argument that matches the given regular expression.
Mock
MockitoAnnotations.MockMock,
so that explicit usage of MockitoAnnotations.initMocks(Object) is not necessary.times(0), see Mockito.times(int)
VerificationWithTimeout
VerificationWithTimeout.times(int)
MethodInvocationReport with a return value.
MethodInvocationReport with a return value.
null argument.
null argument, not necessary of the given class.
VerificationWithTimeout
mock with newHandler.
Answer to be used with Mockito.mock(Class, Answer).
Answer of every mock if the mock was not stubbed.
Answer to be used with Mockito.mock(Class, Answer)
Answer to be used with Mockito.mock(Class, Answer).
AdditionalAnswers.returnsElementsOf(java.util.Collection>)Mockito.mock(Class, Answer)Answer interface
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.
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)
BeanPropertySetter
Short argument matchers.
StackTraceCleaner.String argument that starts with the given prefix.
Mockito.doThrow(Throwable) method for stubbing voids
VerificationWithTimeoutVerificationWithTimeout
VerificationWithTimeout
verify(mock, timeout(100).times(2)).someMethod("some arg");
Answer
VerificationMode that allows combining existing verification modes with 'timeout'.VerificationWithTimeout
OngoingStubbing.then(Answer)
OngoingStubbing.thenAnswer(Answer)
Stubber.doAnswer(Answer)
Mockito.doAnswer(Answer)
OngoingStubbing.thenCallRealMethod()
Stubber.doCallRealMethod()
Mockito.doCallRealMethod()
Mockito.doNothing()
Stubber.doNothing()
OngoingStubbing.thenReturn(Object)
OngoingStubbing.thenReturn(Object, Object[])
Stubber.doReturn(Object)
Mockito.doReturn(Object)
OngoingStubbing.thenThrow(Throwable...)
OngoingStubbing.thenThrow(Class[])
Stubber.doThrow(Throwable)
Stubber.doThrow(Class)
Mockito.doThrow(Throwable)
Mockito.doThrow(Throwable)
|
||||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||