How would you test workflows that depend on an unreliable third-party service?
Answer
Separate tests of your integration contract and failure handling from a small number of live end-to-end checks against the real provider. Use controlled fakes or fault injection for timeouts, rate limits, malformed responses, partial success and recovery, while validating retries, idempotency, circuit breaking and user-visible status. Monitor the live dependency independently and avoid retrying whole tests in ways that turn a real resilience defect into a misleading pass.
Strong answer includes
- separates deterministic contract tests from live provider checks
- injects realistic failures and verifies recovery semantics
- does not use retries to conceal dependency defects
Practical example
For example, a checkout flow depends on a flaky external payment gateway that occasionally times out. The team builds a contract test suite against a WireMock stub that simulates a 30-second timeout, a 429 rate-limit response, and a partial-success response where the charge succeeds but the confirmation callback is lost, verifying the app retries idempotently and shows the user an accurate pending state rather than double-charging; separately, a small canary of 5 real transactions per hour runs against the live sandbox to catch drift the mock doesn't cover.