Chapter 1. Getting Started with Mockito

In this chapter, we will cover the following recipes:

  • Adding Mockito to a project's classpath
  • Getting started with Mockito for JUnit
  • Getting started with Mockito for TestNG
  • Mockito best practices - test behavior, not implementation
  • Adding Mockito hints to exception messages in JUnit (Experimental)
  • Adding additional Mockito warnings to your tests in JUnit (Experimental)

Introduction

For those who don't know Mockito at all, I'd like to write a really short introduction about it.

Mockito is an open source framework for Java that allows you to easily create test doubles (mocks). What makes Mockito so special is that it eliminates the common expect-run-verify pattern (which was present, for example, in EasyMock—please ...

Get Mockito Cookbook 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.