Book Image

MOCKITO COOKBOOK

By : Grzejszczak
Book Image

MOCKITO COOKBOOK

By: Grzejszczak

Overview of this book

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. 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.
Table of Contents (12 chapters)
11
Index

Introduction

Mockito, as the name suggests, is all about working with mocks. It is worth mentioning that before you go and start mocking every class that is in your codebase, it's good to really understand the idea behind mocking and when to mock an object.

While performing unit testing, you will want to test your system in isolation. You're doing it because you want to test a part of the system as a unit and control any external interactions. Remember that in new, well-designed code, your system should follow the SOLID principles (for more details, check out Uncle Bob's blog at http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod and read Agile Software Development, Principles, Patterns, and Practices, Robert C. Martin, which is available at http://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445). The complete description about what SOLID stands for is given as follows:

  • (S) Single responsibility principle: A class should have only a single...