Interface Stubber

All Superinterfaces:
BaseStubber
All Known Implementing Classes:
StubberImpl

@NotExtensible public interface Stubber extends BaseStubber
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style

Example:

  doThrow(new RuntimeException()).when(mockedList).clear();

  //following throws RuntimeException:
  mockedList.clear();
Also useful when stubbing consecutive calls:
  doThrow(new RuntimeException("one")).
  doThrow(new RuntimeException("two"))
  .when(mock).someVoidMethod();
Read more about those methods:

Mockito.doThrow(Throwable[])

Mockito.doAnswer(Answer)

Mockito.doNothing()

Mockito.doReturn(Object)

See examples in javadoc for Mockito