# What are stubs, fakes and mocks in testing?

> A test double stands in for a dependency. Compare a stub clock, fake reminder store and mock mail sender to see what each contributes to the same test.

Source: https://cueapril.com/knowledge/definitions/test-double
Updated: 2026-12-02
Index: https://cueapril.com/llms.txt

## What is a test double, and how do stubs, fakes and mocks differ?

A test double stands in for a dependency during a test. A stub supplies a prepared response, a fake runs a lightweight implementation, and a mock checks expected interactions. Each lets the real code under test run against a controlled collaborator.

## Which double fits the question?

Use a stub to make a dependency return a particular result. Use a fake when later steps need to read what an earlier step wrote. Check a mock’s interactions when sending a command is itself an observable outcome. Keep a separate check for the real dependency’s behaviour at the integration boundary.

## Worked example: Testing a reminder service

A stub clock puts a reminder exactly at its due time. An in-memory fake stores pending reminders. A mock mail sender records the expected recipient and message. The scheduling code still decides which reminder is due, so a mistake in that decision can fail the test.

## Try it on your pull request

Choose a change in your repository and tell Cue April what should happen. Review the proposed checks before they run.

[Try Cue April on your repository](https://app.cueapril.com/sign-up/?next=%2Fquality-start)

## Related reading

- [Hermetic test](https://cueapril.com/knowledge/definitions/hermetic-test)

- [How circular testing gives AI-generated code a false pass](https://cueapril.com/knowledge/explanations/how-circular-testing-happens)

- [Consumer-driven contract](https://cueapril.com/knowledge/definitions/consumer-driven-contract)

[Browse the Knowledge base](https://cueapril.com/knowledge)
