Book Image

Mockito for Spring

By : Sujoy Acharya
Book Image

Mockito for Spring

By: Sujoy Acharya

Overview of this book

Table of Contents (12 chapters)
Mockito for Spring
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exploring Mockito


We need to download the Mockito binary to start working with Mockito. You can download the Mockito jar from http://mockito.org/.

As of December 2014, the latest Mockito version is v2.0.2-beta.

The following section configures Eclipse projects to use Mockito.

Configuring Mockito

To add Mockito JAR files as a project dependency, perform the following steps:

  1. Unzip the Mockito JAR files into a folder.

  2. Open Eclipse.

  3. In Eclipse, create a Java project named MockitoOverview.

  4. Right-click on the project. A pop-up menu will appear. Expand the Build Path menu and click on the Configure Build Path menu item. It will open a wizard. Go to the Libraries tab in the Java build path.

  5. Click on the Add External JARs... button and browse to the Mockito folder.

  6. Select all JAR files and click on OK.

Mocking in action

This section provides examples of mock objects with a stock quote simulation program. The program observes the market trend and performs the following actions:

  • Buying new stocks

  • Selling existing...