Constructor and Description |
---|
StubberImpl() |
Modifier and Type | Method and Description |
---|---|
Stubber |
doAnswer(Answer answer)
Use it for stubbing consecutive calls in
Mockito.doAnswer(Answer) style: |
Stubber |
doNothing()
Use it for stubbing consecutive calls in
Mockito.doNothing() style: |
Stubber |
doReturn(Object toBeReturned)
Use it for stubbing consecutive calls in
Mockito.doReturn(Object) style. |
Stubber |
doThrow(Throwable toBeThrown)
Use it for stubbing consecutive calls in
Mockito.doThrow(Throwable) style: |
<T> T |
when(T mock)
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style
|
public <T> T when(T mock)
Stubber
Example:
doThrow(new RuntimeException()) .when(mockedList).clear(); //following throws RuntimeException: mockedList.clear();Read more about those methods:
See examples in javadoc for Mockito
public Stubber doReturn(Object toBeReturned)
Stubber
Mockito.doReturn(Object)
style.
See javadoc for Mockito.doReturn(Object)
public Stubber doThrow(Throwable toBeThrown)
Stubber
Mockito.doThrow(Throwable)
style:
doThrow(new RuntimeException("one")). doThrow(new RuntimeException("two")) .when(mock).someVoidMethod();See javadoc for
Mockito.doThrow(Throwable)
public Stubber doNothing()
Stubber
Mockito.doNothing()
style:
doNothing(). doThrow(new RuntimeException("two")) .when(mock).someVoidMethod();See javadoc for
Mockito.doNothing()
public Stubber doAnswer(Answer answer)
Stubber
Mockito.doAnswer(Answer)
style:
doAnswer(answerOne). doAnswer(answerTwo) .when(mock).someVoidMethod();See javadoc for
Mockito.doAnswer(Answer)
Copyright © 2018. All rights reserved.