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
About the Author
About the Reviewers

Working with Mockito

Mockito is an open source unit mocking framework for Java. It allows mock object creation, verification, and stubbing.

Mockito was moved to GitHub. You can visit to get the source code, and visit to learn more about Mockito.

Learning the significance of Mockito

We add automated unit tests to run and notify us in case any code breaks the system so that the wrong code can be identified and fixed very quickly.

But when an automated test suite takes time to execute, for instance, two hours to complete a build, it defeats the purpose of quick feedback. In Test-Driven Development (TDD), automated JUnit test cases are run to provide quick feedback. Here, a test should not take more than a few milliseconds to execute. When a test suite takes hours to execute, it blocks the progress of development.

A test suite takes time because individual tests take time to execute. The following are some reasons behind delays...