Testing Orchestrated Sagas
Learn how to test orchestration-based sagas, covering unit tests for compensation paths, integration tests with simulated service failures, and end-to-end verification of saga completion.
Why Test Sagas?
An orchestration saga coordinates multiple services through a central orchestrator. A bug in the orchestrator can leave the system in an inconsistent state across services.
Testing sagas is harder than testing a single function because you must verify both the happy path and every compensation path.
- Did each step execute in order?
- Did failures trigger the right compensations?
- Is the final state consistent?
The Testing Pyramid for Sagas
Apply the classic testing pyramid:
- Unit tests — the orchestrator's decision logic in isolation.
- Integration tests — the orchestrator talking to real or stubbed services.
- End-to-end tests — the full saga across all services.
Most tests should be unit tests because they are fast and deterministic.
All lessons in this course
- Designing Saga Orchestrators
- State Machines for Orchestration
- Implementing with a Workflow Engine
- Testing Orchestrated Sagas