How do you design automated tests for an event-driven microservices system where services talk through a message broker?
What the interviewer wants to hear
- Unit test handlers with in-memory events
- Component tests with a real broker in containers
- Contract tests or schema registry for event shapes
- Poll with timeouts for async outcomes, use correlation ids
- Test retries, duplicates, ordering and dead-letter queues
Model answer
I test at several levels. Each event handler gets unit tests with in-memory events, covering business rules. Then component tests run each service with a real broker, like Kafka or RabbitMQ, started in containers with Testcontainers: publish an event, then poll with a timeout until the expected side effect appears, never fixed sleeps. Event shapes are protected with contract tests or a schema registry with compatibility rules, so a producer cannot break consumers silently. Event-driven systems fail in special ways, so I deliberately test duplicate delivery to prove handlers are idempotent, out-of-order events, consumer crashes and retries, and that poison messages land in the dead-letter queue. A few end-to-end tests cover critical flows using correlation ids so I can trace one order through every service and debug failures from logs.
Can you answer it under time pressure?
Take a timed hard round and get scored on every answer.
More hard Automation Test Engineer questions
- Design a test automation strategy for a product with 15 microservices, a web app and a mobile app.
- Your regression suite has grown to 3 hours. How do you bring feedback time under 15 minutes?
- What does testing in production mean, and how would you do it safely?
- What is your view on AI-based and self-healing test automation tools in 2026?
- Developers keep changing the UI and breaking your tests. How do you fix this at the team level, not just in your code?
- How do you measure whether your test automation is healthy and worth the investment?
- Your company has 2,000 Selenium tests and wants to move to Playwright. How would you plan the migration?
- The E2E suite fails on about 30% of runs and developers now ignore it. How do you turn this around?
- Your product adds an AI assistant built on a large language model. Its answers vary between runs. How would you automate testing for it?