Mockito is a testing framework that creates external dependencies (which is called mocking) which is used to test/simulate the behavioral patterns of the software and generate reports about it. Frameworks like Mockito fake or “mock” the external dependencies so that the object being tested has a consistent interaction with the outside dependencies. Mockito streamlines the delivery of the external dependencies that are not subjects of the test. Why Mockito? Compared to its main Java competitors EasyMock and jMock, Mockito, it is the most widely used mocking framework.
This book consists of recipes that depict the usage of a vast majority of Mockito functionalities in real-life examples. It goes beyond the documentation and covers how Mockito works and shows the steps to write effective tests using Mockito. It begins with getting to know the Mockito configuration, then you will learn how to create mocks and stubs, and afterwards you will be shown how to write good tests using Mockito together with how to properly stub behavior of your test objects. We'll finish by showing you some of the most interesting Mockito extension-based tools together with a comparison of the most widely used mocking frameworks.
This is a focused guide with lots of practical recipes with presentations of business issues and presentation of the whole test of the system. This book shows the use of Mockito's popular unit testing frameworks such as JUnit, PowerMock, TestNG, and so on.
Who this book is for
If you are a software developer with no testing experience (especially with Mockito) and you want to start using Mockito in the most efficient way then this book is for you. This book assumes that you have a good knowledge level and understanding of Java-based unit testing frameworks.