Reader small image

You're reading from  Pragmatic Test-Driven Development in C# and .NET

Product typeBook
Published inSep 2022
PublisherPackt
ISBN-139781803230191
Edition1st Edition
Right arrow
Author (1)
Adam Tibi
Adam Tibi
author image
Adam Tibi

Adam Tibi is a London-based software consultant with over 22 years of experience in .NET, Python, the Microsoft stack, and Azure. He is experienced in mentoring teams, designing architecture, promoting agile and good software practices, and, of course, writing code. Adam has consulted for blue-chip firms including Shell, Lloyds Bank, Lloyd’s of London, Willis Towers Watson, and for a mix of start-ups. As a consultant who has a heterogeneous portfolio of clients, he has gained a solid understanding of the TDD intricacies, which he has transferred into this book.
Read more about Adam Tibi

Right arrow

Understanding and using test doubles

You would rarely write a unit test without using a test double. Think of the term double in the same sense as a Hollywood stunt, where a stunt takes the place of a real actor in some situations. Test double is an umbrella term for an object that is used to replace a dependency with a test equivalent (double) for the sake of testing a SUT. They are meant to satisfy one or more of the following requirements:

Requirement 1: Enable the test code to compile.

Requirement 2: Eliminate side effects according to the unit test requirements.

Requirement 3: Embed a canned (predetermined) behavior that relates somehow to the real behavior.

Requirement 4: Take a note of and verify the activities that were exerted on a dependency within a unit test (we will name this requirement later as spying).

We will be referring to these four conditions when we discuss individual test double types, so you may want to bookmark this section.

Do you want your...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Pragmatic Test-Driven Development in C# and .NET
Published in: Sep 2022Publisher: PacktISBN-13: 9781803230191

Author (1)

author image
Adam Tibi

Adam Tibi is a London-based software consultant with over 22 years of experience in .NET, Python, the Microsoft stack, and Azure. He is experienced in mentoring teams, designing architecture, promoting agile and good software practices, and, of course, writing code. Adam has consulted for blue-chip firms including Shell, Lloyds Bank, Lloyd’s of London, Willis Towers Watson, and for a mix of start-ups. As a consultant who has a heterogeneous portfolio of clients, he has gained a solid understanding of the TDD intricacies, which he has transferred into this book.
Read more about Adam Tibi