Jump to ratings and reviews
Rate this book

Mockito Cookbook

Rate this book
Over 65 recipes to get you up and running with unit testing using Mockito If you are a software developer with no testing experience (especially with Mockito) and you want to start using Mockito in the most efficient way then this book is for you. This book assumes that you have a good knowledge level and understanding of Java-based unit testing frameworks. Mockito is a testing framework that allows you to easily create test doubles (mocks) of the system under test's collaborators. You can use mocks to better simulate the behavioral patterns of your software in isolation to receive feedback from tests as soon as possible. This book consists of recipes that depict the usage of a vast majority of Mockito functionalities in real-life examples. It goes beyond the documentation and covers how Mockito works and shows the steps to write effective tests using Mockito. This is a focused guide with lots of practical recipes of business issues and presentation of the entire test of the system. This book shows the use of Mockito's popular unit testing frameworks such as JUnit, PowerMock, TestNG, and so on.

284 pages, Paperback

First published January 1, 2014

5 people are currently reading
21 people want to read

About the author

Marcin Grzejszczak

2 books17 followers
Co-author of SmartTesting, author of Hands-On Guide to Spring Cloud Contract: Creating Consumer-Driven Contracts to Leverage Contract Tests and Improve Your Code and co-author of Applied Continuous Delivery Live Lessons. Co-founder of the Warsaw Groovy User Group and Warsaw Cloud Native Meetup and the DiverseIT initiative. Author of Mockito Instant and Mockito Cookbook books.

Lead of Spring Cloud Sleuth, Spring Cloud Contract and Cloud Pipelines projects at VMware

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
2 (33%)
4 stars
2 (33%)
3 stars
2 (33%)
2 stars
0 (0%)
1 star
0 (0%)
Displaying 1 of 1 review
3 reviews
August 22, 2014
“Mockito Cookbook” is a useful book, by means of which, you can discover Mockito testing framework and start using it in the matter of days.

It starts with the short introduction of the test doubles, set up of Mockito for JUnit and TestNG, and a very basic example of using it. The first chapter of the book also gives concise recommendations on using Mockito.

Further the book focuses on the creation of different types of test doubles (stubs, mocks, spies) and their behavior. Each chapter gives examples, using standard Mockito API and BDD Mockito API. The section ends with the description of verification of test doubles and their behavior.

Final chapters are dedicated to the integration testing with Mockito and Spring framework and comparison of mocking libraries: Mockito, JMockit, JMock, and Spock.

In general, I have a very positive impression after reading the book. I was a complete newbie in Mockito before starting reading it. Of course, it didn’t make me an expert in a week; however, I started understanding BDD code and Mockito API much better. It is much easier for me now to understand test cases, which are written by my colleagues.

Unfortunately, I have to note that the author repeats certain phrases from chapter to chapter. That space could have been used for a bit deeper explanation of best practices or theoretical aspects (even if it is a cookbook).

Nevertheless, if you are a newbie in BDD, TDD, and Mockito and you want to become quickly up to speed with the framework, this book is the right choice.
Displaying 1 of 1 review

Can't find what you're looking for?

Get help and learn more about the design.