Preface

We can acquire knowledge in different ways. On one side is theory, and on the other side is the application of theory. Both are important and both make us better. Theoretical knowledge can provide us with a deep understanding of the concept through the experiences of others, but a practical application can give us a deep understanding through the reality of life and the act of doing.

I was looking for a Mockito framework guide that could teach me the practical application of the framework, but I didn't find any book or article. Then, I decided to start writing a book that can focus on both the theoretical aspect and the practical application, so that readers can get a deep understanding of the concepts through the act of doing.

This book is an advanced-level guide that will help software developers to get complete expertise in unit testing using Mockito as the mocking framework. The focus of the book is to provide readers with comprehensive details on how effectively Mockito can be used for mocking external dependencies in Java application, web application, legacy code, GWT, and SOA.

Armed with the knowledge of advanced JUnit concepts and mocking framework essentials, you will be pleasantly surprised at how quickly and easily you can write high-quality, clean, readable, testable, maintainable, and extensible code.

What this book covers

Chapter 1, Exploring Test Doubles, covers the concept of automated unit tests, talks about the characteristics of a good unit test, and explores the test's doubles. It provides examples of dummy objects, fake objects, stubs, mock objects, and spies.

Chapter 2, Socializing with Mockito, focuses on getting the reader quickly started with the Mockito overview, unit test qualities, and the significance of Mockito in unit testing. It also explains and provides examples of stubbing, answering, throwing exceptions, argument matchers, and method call verification. The Mockito architecture is also uncovered.

Chapter 3, Accelerating Mockito, illustrates advanced Mockito framework topics, such as working with void methods, throwing exceptions from void methods, writing callbacks for void methods, returning values using doReturn, void method chaining, calling original methods, Mockito annotations, verifying arguments using an argument captor, verifying an invocation order, spying objects using spy, changing default Mockito settings, resetting mock objects, inline stubbing, and mock details.

Chapter 4, Behavior-driven Development with Mockito, unfolds the BDD concepts, BDD examples, and writing BDD style tests with Mockito.

Chapter 5, Unit Testing the Legacy Code with Mockito, explores legacy code, testing impediments, design for testability, and unit testing the legacy code with Mockito and PowerMock. By the end of this chapter, the reader will be able to write JUnit tests for a legacy code with Mockito and PowerMock, refactor the legacy code to make it unit testable, and design code to bypass the testing impediments.

Chapter 6, Developing SOA with Mockito, deals with web services, explores SOAP and RESTful web services with examples, and helps us to write JUnit tests for the web services with Mockito to mock out the web service framework dependencies.

Chapter 7, Unit Testing GWT Code with Mockito, provides an overview of Ajax/GWT, explains the MVP pattern and loose coupling, and provides examples and strategies to mock GWT widgets using Mockito.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.174.253