Book Image

Mockito Essentials

By : Sujoy Acharya
Book Image

Mockito Essentials

By: Sujoy Acharya

Overview of this book

Table of Contents (14 chapters)

Working with Mockito


This section provides an overview of Mockito. Here is the official Mockito logo:

The following topics are covered in this section:

  • Configuring Mockito

  • Stubbing method calls

  • Throwing exceptions

  • Matching method arguments

  • Verifying method calls

Download the latest Mockito binary ZIP folder from the following link and add it to the project dependency. The recommended channel for getting Mockito is Maven (or Gradle), or download it directly from the central Maven repository if you need to get the JAR files manually from either http://central.maven.org/maven2/org/mockito/mockito-all/ or http://central.maven.org/maven2/org/mockito/mockito-core/.

As of April 2014, the latest Mockito version is 1.9.5.

Adding a Mockito dependency

The following steps describe how Mockito JAR files can be added as project dependency:

  1. Extract the JAR files into a folder.

  2. Launch Eclipse.

  3. Create an Eclipse project named 3605OS_Socializing_with_Mockito.

  4. Go to the Libraries tab in the project's build path.

  5. Click on...