PrincipalAPI & Integration Testing
How would you design an API test suite for a microservices architecture?
- microservices
- test strategy
- architecture
Answer it first, then compare. Nothing here is saved or scored.
Model answer
Layered strategy: (1) Unit tests within each service, fast, mocked dependencies. (2) Contract tests between services (Pact or similar), run in isolation. (3) Service-level integration tests with real database but mocked external services. (4) End-to-end API tests hitting the full stack through the API gateway. (5) Chaos testing, inject failures in service mesh. (6) Each team owns their service tests, platform team owns e2e. (7) Shared test infrastructure: service mesh test doubles, test data factories, observability for test failures.
What interviewers listen for
- Schema-first thinkingYou validate response shape before you assert on values, every time.
- Status-code literacyYou can defend why 401 vs 403 vs 422 matters for the consumer.
- Contract awarenessYou know when consumer-driven contract tests beat end-to-end checks.
- Auth fluencyYou can describe rotating tokens across parallel workers without secrets in logs.