Knowledge Maxxing
← Back to topic library
Dev MaxxingIntermediateTesting75 sec

Test double

A test double is a stand-in object used in a test to replace a real dependency, such as a database or external service, so the test stays fast and isolated.

Prerequisite: Unit test

What matters

Using a test double lets a unit test avoid depending on slow or unreliable external systems, but relying on one also means the test isn't checking the real dependency's actual behavior.

Example

A test might use a fake payment service that always reports success, rather than calling a real payment provider during every test run.

Common misconception

A test relying entirely on test doubles does not prove the real integration actually works; that gap is why integration tests against real dependencies still matter.

Recall question

Why doesn't a test using only test doubles prove the real integration works?

Keywords and related concepts

test doublemockfake dependencyunit test

Related topics

Unit test
Dev MaxxingIntermediate
Integration test
Dev MaxxingIntermediate