Appendix A. jMock2 Cheat Sheet
Introduction
We use jMock2 as our mock object framework throughout this book. This chapter summarizes its features and shows some examples of how to use them. We’re using JUnit 4.6 (we assume you’re familiar with it); jMock also supports JUnit3. Full documentation is available at www.jmock.org.
We’ll show the structure of a jMock unit test and describe what its features do. Here’s a whole example:
Test Fixture Class
First, we set up the test fixture class by creating its Mockery
.
For the object under test, a
Get Growing Object-Oriented Software, Guided by Tests 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.