Chapter 10Using Mock Objects

It’s a safe bet that you find your own system hard to test. Perhaps you’re thinking that the rest of this book makes it all look too easy. “It must be nice to have a system that supports writing unit tests out of the box, but it doesn’t match my reality,” says Pat.

In this chapter you’ll learn how to employ mock objects to break dependencies on pain-inducing collaborators, gaining a tool that will help you get past an ever-present hurdle. With mocking, you’ll be able to see more of the light at the end of the unit-testing tunnel.

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.