TL;DR
Continuous Integration (CI) pipelines often rely on Testcontainers and mocks, which fail to simulate nuanced production failures. Fakes, which are in-memory implementations of dependencies that can mimic realistic states and failures, offer a more effective alternative.
✦ Why It Matters
Engineers should consider using fakes to better simulate production-like failures and improve test coverage.
Key Takeaways
Full Summary
CI pipelines typically use Testcontainers to spin up services like Kafka, Postgres, and Redis for testing, but these tools only provide binary outcomes: services are either fully operational or completely down. This approach fails to replicate partial failures that occur in production, such as a Kafka broker losing a specific partition or a Postgres replica lagging behind.
Mocks, another common testing tool, can lead to tests that are tightly coupled to implementation details, making them less flexible. Fakes, however, are real implementations of a dependency's interface that run in-memory, allowing for realistic state management and the ability to inject failures at a granular level.
This capability enables developers to simulate complex failure scenarios that are more representative of real-world conditions. As a result, using fakes can lead to the discovery of bugs that would otherwise remain hidden, ultimately improving software reliability and performance.
Related