The problem with testing microservices
In a monolith, one API test suite covers most of the system. In a microservice architecture, you have multiple services, each with its own API, data store, and deployment cadence. Testing end-to-end is slow and brittle. Testing in isolation misses integration issues.
The three-layer approach
- Contract tests: Each service verifies its API contract (request/response shape, status codes, error handling). Fast, isolated, runs on every PR.
- Integration tests: Test service pairs with real dependencies but mocked downstream services. Catches interaction issues without requiring full deployment.
- Smoke tests: Deploy to a test environment and run critical path checks across the real system. Run before release.
What to automate
- Every public API endpoint should have a contract test.
- Critical user journeys spanning multiple services need integration tests.
- Health check and readiness endpoints need smoke tests in production.
What not to do
Do not build one giant end-to-end test suite that calls every service. It will be slow, flaky, and hard to maintain. Prefer faster, more focused tests at each layer.