# Fake (Testing)

> A small copy of a real part. It works, but only in tests.

**Field:** Software Development  
**Category:** Testing & Quality  
**Also known as:** Fake, Fake Object, In-Memory Fake

## Think of it like

Think of it like a toy kitchen. You can really cook pretend food, but it is not a real stove.

## Definition

A fake is a test double that really works, but in a simple, cheap way. A common one is an in-memory database that keeps data in a list instead of on disk. It behaves like the real thing for the cases your tests need. It is much faster and needs no set-up. Fakes are not fit for real use, because they skip things like safety and saving data for good.

## Example

Jack's tests use a fake user store that keeps users in a list. 500 tests run in 2 seconds, with no database to start.

## Why it matters

Fakes let lots of tests run fast. They still act like the real part, not just give one set answer.

## Common mistake

Letting the fake drift from the real thing. Run the same few tests against both now and then.

## Three principles

- **Really works.** In a simple way.
- **Fast and cheap.** Often kept in memory.
- **Tests only.** Never for real use.

## Related terms

- [Test Double](https://learn.benibix.com/term/development/test-double)
- [Stub (Testing)](https://learn.benibix.com/term/development/stub)
- [Mock (Testing)](https://learn.benibix.com/term/development/mock)
- [Database](https://learn.benibix.com/term/development/database)

## Told apart from

- [Fake vs Stub](https://learn.benibix.com/compare/fake-vs-stub): People think a fake is the same as a stub, and it is not. A stub hands back a fixed answer, whatever you ask it. A fake really works, just in a small way, such as a pretend bank that keeps balances in memory. Put money in a fake and you can take it out again. A stub cannot do that.

---

Source: https://learn.benibix.com/term/development/fake
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.
