Fakes
Fakes are a type of test double used in software testing to simulate the behavior of real dependencies, such as databases, APIs, or external services, in a controlled and simplified manner. They are typically lightweight implementations that mimic the interface of the real component but with predetermined responses or behaviors, allowing for isolated and predictable testing of the system under test. Unlike mocks or stubs, fakes often provide a working but simplified version of the dependency, such as an in-memory database instead of a real one.
Developers should learn and use fakes when they need to test components in isolation from external dependencies that are slow, unreliable, or difficult to set up, such as network services or complex databases. This is particularly useful in unit testing to ensure fast, repeatable tests without side effects, and in integration testing to simulate external systems during development or in CI/CD pipelines. Fakes help improve test reliability and speed by avoiding flaky tests caused by real-world dependencies.