Skip to Content
Growing Object-Oriented Software, Guided by Tests
book

Growing Object-Oriented Software, Guided by Tests

by Steve Freeman, Nat Pryce
October 2009
Intermediate to advanced
384 pages
8h 54m
English
Addison-Wesley Professional
Content preview from Growing Object-Oriented Software, Guided by Tests

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:

image

Test Fixture Class

First, we set up the test fixture class by creating its Mockery.

image

For the object under test, a

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Test Driven Development: By Example

Test Driven Development: By Example

Kent Beck
Coding with AI: The End of Software Development as We Know It

Coding with AI: The End of Software Development as We Know It

Tim O'Reilly, Addy Osmani, Gergely Orosz, Kent Beck, Camille Fournier, Avi Flombaum, Maxi Ferreira, Harper Reed, Jay Parikh, Birgitta Böckeler, Angie Jones, Craig McLuckie, Patty O’Callaghan, Chip Huyen, swyx, Andrew Stellman, Phillip Carter, Nikola Balic, Brett Smith, Chelsea Troy, Lili Jiang

Publisher Resources

ISBN: 9780321574442Purchase book