Book description
A practical guide to get you up and running with unit testing using Mockito
In Detail
Whether you are new to JUnit testing and mocking or a seasoned Mockito expert, this book will provide you with the skills you need to successfully build and maintain meaningful JUnit test cases and effectively mock external dependencies. At the beginning, this book deals with dummy and fake objects and then moves on to exploring stubs followed by an example on spying. Then, it will show you how to make legacy code testable, mock external dependencies using Mockito, and write testable code for greenfield projects. You will also gain an insight on the concepts of Service-oriented Architecture (SOA) as well as understand how to unit test RESTful web services with Mockito. By sequentially working through the steps in each chapter, you will quickly learn the features of Mockito.
Mockito Essentials will ensure your success with these concepts, tools, and frameworks.
What You Will Learn
- Explore test doubles and work with dummy, spy, fake, stub, and mock objects
- Uncover the Mockito architecture and build a custom mocking framework
- Mock, stub, and spy external code dependencies using Mockito
- Practice Behavior-driven Development (BDD) with Mockito
- Make legacy code testable by mocking and spying dependencies
- Mock GWT and web service dependencies using Mockito
- Discover argument captors, inline stubbing, and resetting mock objects
Table of contents
-
Mockito Essentials
- Table of Contents
- Mockito Essentials
- Credits
- About the Author
- About the Reviewers
- www.PacktPub.com
- Preface
- 1. Exploring Test Doubles
- 2. Socializing with Mockito
-
3. Accelerating Mockito
-
Learning advanced Mockito features
- Working with void methods
- Throwing exceptions from void methods
- Working with void method callbacks
- Learning doCallRealMethod and doNothing
- Exploring doReturn
- Verifying arguments using ArgumentCaptor
- Verifying an invocation order
- Spying objects
- Exploring Mockito annotations
- Changing the default Mockito settings
- Resetting mock objects
- Working with inline stubbing
- Determining mock details
- Summary
-
Learning advanced Mockito features
- 4. Behavior-driven Development with Mockito
- 5. Unit Testing the Legacy Code with Mockito
- 6. Developing SOA with Mockito
- 7. Unit Testing GWT Code with Mockito
- Index
Product information
- Title: Mockito Essentials
- Author(s):
- Release date: October 2014
- Publisher(s): Packt Publishing
- ISBN: 9781783983605
You might also like
book
Mockito Made Clear
Mockito is the most popular framework in the Java world for automating unit testing with dependencies. …
book
Mockito Cookbook
Over 65 recipes to get you up and running with unit testing using Mockito In Detail …
book
Mockito for Spring
Learn all you need to know about the Spring Framework and how to unit test your …
book
JUnit in Action, Third Edition
JUnit is the gold standard for unit testing Java applications. Filled with powerful new features designed …