Instant Mock Testing with PowerMock

Writing good unit tests can be hard - make it easy with a quick start to PowerMock
Preview in Mapt

Instant Mock Testing with PowerMock

Deep Shah

Writing good unit tests can be hard - make it easy with a quick start to PowerMock
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.50
RRP $14.99
Save 29%
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$10.50
$29.99 p/m after trial
RRP $14.99
Subscription
eBook
Start 30 Day Trial

Frequently bought together


Instant Mock Testing with PowerMock Book Cover
Instant Mock Testing with PowerMock
$ 14.99
$ 10.50
Mastering Windows Penetration Testing Book Cover
Mastering Windows Penetration Testing
$ 39.99
$ 28.00
Buy 2 for $28.00
Save $26.98
Add to Cart

Book Details

ISBN 139781783289950
Paperback82 pages

Book Description

Writing good unit tests can be hard in situations where we have to deal with static, final, or private methods. Sometimes, even a good design is sacrificed for the sake of testability. A mocking framework’s ability to create mocks for almost any scenario enables us to focus on accurately programming for a business environment.

Starting with a basic example of how to create a mock and verify a method invocation Instant Testing with PowerMock then demonstrates various features of PowerMock using clear, practical, step-by-step recipes. By the end of this book, you will be able to write unit tests for almost any scenario and suppress unwanted behaviour to effectively unit test your code.

Moving on from the basics, you will learn to write unit tests for static, final, and private methods, and write flexible unit tests using argument matchers. Following on from this, you will also learn how to mock a few methods of a class, and invoke real implementation of others using partial mocks or spies. This book will teach you the tricks of the trade that will enable you to write good unit tests for a wide range of scenarios.

Table of Contents

Chapter 1: Instant Mock Testing with PowerMock
Saying Hello World! (Simple)
Getting and installing PowerMock (Simple)
Mocking static methods (Simple)
Verifying method invocation (Simple)
Mocking final classes or methods (Simple)
Mocking constructors (Medium)
Understanding argument matchers (Medium)
Understanding the Answer interface (Advanced)

What You Will Learn

  • Learn how to mock final classes and methods
  • Use argument matchers to write flexible tests
  • Invoke private methods and verify the internal state of a class
  • Suppress unwanted constructors, methods, fields, and static initializers
  • Set up mocking code once and use Mock Policies to avoid writing repetitive code

Authors

Table of Contents

Chapter 1: Instant Mock Testing with PowerMock
Saying Hello World! (Simple)
Getting and installing PowerMock (Simple)
Mocking static methods (Simple)
Verifying method invocation (Simple)
Mocking final classes or methods (Simple)
Mocking constructors (Medium)
Understanding argument matchers (Medium)
Understanding the Answer interface (Advanced)

Book Details

ISBN 139781783289950
Paperback82 pages
Read More

Read More Reviews

Recommended for You

Mockito Cookbook Book Cover
Mockito Cookbook
$ 26.99
$ 18.90
Java EE 7 Developer Handbook Book Cover
Java EE 7 Developer Handbook
$ 35.99
$ 25.20
Mastering Unit Testing Using Mockito and JUnit Book Cover
Mastering Unit Testing Using Mockito and JUnit
$ 26.99
$ 18.90
Google Maps JavaScript API Cookbook Book Cover
Google Maps JavaScript API Cookbook
$ 26.99
$ 18.90
Jenkins Essentials Book Cover
Jenkins Essentials
$ 23.99
$ 16.80
Software Testing using Visual Studio 2012 Book Cover
Software Testing using Visual Studio 2012
$ 29.99
$ 21.00