Chapter 10. Mocking Libraries Comparison

In this chapter, we will cover the following recipes:

  • Mockito versus EasyMock
  • Mockito versus JMockit
  • Mockito versus jMock
  • Mockito versus Spock

Introduction

In this chapter, we will take a look at other mocking frameworks that are quite well known in the Java world. The idea of this chapter is not to state whether one mocking framework is better than Mockito, but to point out differences in both their syntax and approach.

Remember that the examples presented in this chapter are very simple and do not show all of the possible ways of using the mocking frameworks, since you could write books about any of them.

Before moving forward, it's worth mentioning the difference between a strict mock and a non-strict one:

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.