Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • MOCKITO COOKBOOK
  • Toc
  • feedback
MOCKITO COOKBOOK

MOCKITO COOKBOOK

By : Grzejszczak
4.3 (4)
close
MOCKITO COOKBOOK

MOCKITO COOKBOOK

4.3 (4)
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)
close
11
Index

Introduction

As explained in the previous chapters, Mockito is all about creating mocks and stubbing their behavior. It's worth taking another look at the differences between mocks and stubs in order to properly distinguish possible actions that can be taken on either of them. In his xUnit patterns (http://xunitpatterns.com/Test%20Double%20Patterns.html), Gerard Meszaros describes stubs and mocks as follows:

  • Stub: This is an object that has predefined answers to method executions made during the test
  • Mock: This is an object that has predefined answers to method executions made during the test and that has recorded expectations of these executions

Mockito does not distinguish this separation, so each test double, regardless of its purpose, is considered to be a mock. This chapter will focus on showing you numerous ways of the stubbing behavior of mocks in order to simulate real interactions. We'll cover stubbing methods that return values and those that are void. We'll simulate...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete