|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mockito.internal.stubbing.VoidMethodStubbableImpl<T>
public class VoidMethodStubbableImpl<T>
Constructor Summary | |
---|---|
VoidMethodStubbableImpl(T mock,
InvocationContainerImpl invocationContainerImpl)
|
Method Summary | |
---|---|
T |
on()
Choose void method for stubbing. |
VoidMethodStubbable<T> |
toAnswer(Answer<?> answer)
Stubs a void method with generic Answer |
VoidMethodStubbable<T> |
toReturn()
Stubs void method to 'just return' (e.g. |
VoidMethodStubbable<T> |
toThrow(java.lang.Throwable throwable)
Stubs void method with an exception. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VoidMethodStubbableImpl(T mock, InvocationContainerImpl invocationContainerImpl)
Method Detail |
---|
public VoidMethodStubbable<T> toThrow(java.lang.Throwable throwable)
VoidMethodStubbable
stubVoid(mock).toThrow(new RuntimeException()).on().someMethod();
If throwable is a checked exception then it has to
match one of the checked exceptions of method signature.
See examples in javadoc for Mockito.stubVoid(T)
toThrow
in interface VoidMethodStubbable<T>
throwable
- to be thrown on method invocation
public VoidMethodStubbable<T> toReturn()
VoidMethodStubbable
Only use this method if you're stubbing consecutive calls.
For example:
stubVoid(mock)
.toReturn()
.toThrow(new RuntimeException())
.on().foo(10);
See examples in javadoc for Mockito.stubVoid(T)
toReturn
in interface VoidMethodStubbable<T>
public VoidMethodStubbable<T> toAnswer(Answer<?> answer)
VoidMethodStubbable
Answer
For Example:
stubVoid(mock)
.toAnswer(new Answer() {
public Object answer(InvocationOnMOck invocation) {
Visitor v = (Visitor) invocation.getArguments()[0];
v.visitMock(invocation.getMock());
return null;
}
})
.on().accept(any());
toAnswer
in interface VoidMethodStubbable<T>
answer
- the custom answer to execute.
public T on()
VoidMethodStubbable
stubVoid(mock).toThrow(new RuntimeException()).on().someMethod("some arg");
See examples in javadoc for Mockito.stubVoid(T)
on
in interface VoidMethodStubbable<T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |