Chapter 2Work with the Mockito API

I’ve always been a good test taker—part of what I call the Game of School, which is very different from getting an education. In the Game of School, your primary task is to figure out what teachers want to hear and how they want to hear it. That knowledge comes in handy when you want to pass a test without studying much. Just like that teacher, Mockito expects certain things, and right now they’re a mystery.

The game begins with the Mockito API. You’ll need to know what it does and how it expects to be invoked. We’ll start with creating mocks, either using the mock method or using the annotations @Mock and @InjectMocks. Then we’ll move on to setting expectations on our mocks, and finally to verifying that the ...

Get Mockito Made Clear now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.