Package org.mockito

Mockito is a mock library for java - see Mockito class for for usage.


Interface Summary
BDDMockito.BDDMyOngoingStubbing<T> See original OngoingStubbing
BDDMockito.BDDStubber See original Stubber
InOrder Allows verification in order.
MockSettings Allows mock creation with additional mock settings.
ReturnValues Deprecated. Instead, please use Answer interface

Class Summary
AdditionalMatchers See Matchers for general info about matchers.
ArgumentCaptor<T> Use it to capture argument values for further assertions.
ArgumentMatcher<T> Allows creating customized argument matchers.
BDDMockito Behavior Driven Development style of writing tests uses //given //when //then comments as fundamental parts of your test methods.
Matchers Allow flexible verification or stubbing.

MockitoAnnotations MockitoAnnotations.initMocks(this); initializes fields annotated with Mockito annotations.

Enum Summary
Answers Enumeration of pre-configured mock answers

Annotation Types Summary
Captor Allows shorthand ArgumentCaptor creation on fields.
InjectMocks Allows shorthand mock and spy injection. Minimizes repetitive mock and spy injection.
Mock Allows shorthand mock creation. Minimizes repetitive mock creation code. Makes the test class more readable. Makes the verification error easier to read because the field name is used to identify the mock.

   public class ArticleManagerTest extends SampleBaseTestCase {

       @Mock private ArticleCalculator calculator;
       @Mock(name = "dbMock") private ArticleDatabase database;
       @Mock(answer = RETURNS_MOCKS) private UserProvider userProvider;
       @Mock(extraInterfaces = {Queue.class, Observer.class}) private  articleMonitor;

       private ArticleManager manager;

       @Before public void setup() {
           manager = new ArticleManager(userProvider, database, calculator, articleMonitor);

   public class SampleBaseTestCase {

       @Before public void initMocks() {
MockitoAnnotations.Mock Deprecated.
Spy Allows shorthand wrapping of field instances in an spy object.

Package org.mockito Description

Mockito is a mock library for java - see Mockito class for for usage.