# Test Double

> A stand-in that takes the place of a real part during a test.

**Field:** Software Development  
**Category:** Testing & Quality  
**Also known as:** Test Doubles, Fake Object

## Think of it like

Think of it like a stunt double in a film. It stands in for the real star.

## Definition

A test double is a stand-in that replaces a real part of the system during a test. You use one when the real thing is slow, costs money or is hard to control. A payment service, an email sender and the clock are common things to swap out. Mocks, stubs, fakes and spies are all kinds of test double. The name comes from a stunt double in films.

## Example

Jack's checkout test cannot charge a real card each run. He swaps the payment service for a test double that always says paid.

## Why it matters

Tests stay fast, free and the same each time. That holds even when the real part is slow or out of your hands.

## Common mistake

Replacing so much with doubles that the test only checks the doubles. Keep some tests that use the real parts.

## Three principles

- **A stand-in.** For a real part.
- **For slow or costly parts.** Payments, email, the clock.
- **Several kinds.** Mock, stub, fake, spy.

## Related terms

- [Mock (Testing)](https://learn.benibix.com/term/development/mock)
- [Stub (Testing)](https://learn.benibix.com/term/development/stub)
- [Unit Test](https://learn.benibix.com/term/development/unit-test)
- [Integration Test](https://learn.benibix.com/term/development/integration-test)

---

Source: https://learn.benibix.com/term/development/test-double
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
