Chapter 1. Instant Mock Testing with PowerMock

Welcome to Instant Mock Testing with PowerMock. This book will demonstrate the effective use of this versatile open source mocking framework. The recipes described in this book will introduce most of the concepts of PowerMock (see that will enable us to use it effectively.

PowerMock enables us to write good unit tests for even the most untestable code. Most of the mocking frameworks in Java cannot mock static methods or final classes. But using PowerMock, we can mock almost any class.

PowerMock does not intend to reinvent the wheel. It extends existing frameworks such as EasyMocks (see and Mockito (see

Get Instant Mock Testing with PowerMock now with O’Reilly online learning.

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