My Digital Garden

System Under Test

System under Test

A Test Double is a non-production code dependency that sufficiently mimics product behaviour to support testing.

Gerard Meszaros identifies 5 types of Test Double:


Frequently, the final release software consists of a complex set of objects or procedures interacting together to create the final result. In automated unit testing, it may be necessary to use objects or procedures that look and behave like their release-intended counterparts, but are actually simplified versions that reduce the complexity and facilitate testing. A test double is a generic (meta) term used for these objects or procedures.


Vladimir Khorikov simplifies to key two types:

they can all be grouped together into just two types: mocks and stubs

  • Mocks help to emulate and examine outgoing interactions. These interactions are calls the system under test (SUT) makes to its dependencies to change their state.
  • Stubs help to emulate *incoming interactions. These interactions are calls the SUT makes to its dependencies to get input data.