O'Reilly logo

Instant Mock Testing with PowerMock by Deep Shah

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 http://code.google.com/p/powermock/) 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 http://www.easymock.org/) and Mockito (see http://code.google.com/p/mockito/

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required