InterviewStack.io LogoInterviewStack.io

Mocking, Stubbing, and Test Isolation Questions

Techniques for isolating tests from external dependencies using mocks, stubs, and test doubles. Understanding when to mock vs. when to use real services, and how to make tests reliable while still validating real behavior.

EasyTechnical
45 practiced
Compare using an in-memory database (for example SQLite or H2) versus mocking the data-access layer in tests. As an SDET explain the trade-offs across fidelity, speed, maintenance, migrations, transactional semantics, and propose guidelines for which approach to use in unit, integration, and CI environments.
HardTechnical
41 practiced
You need to introduce automated tests into a large legacy monolith with minimal refactoring. Describe practical 'seams' and techniques you can create to allow mocking and testability (for example: extract adapters, use dependency wrappers, runtime interception, and characterization tests). Provide step-by-step actions to increase coverage while minimizing risk.
HardTechnical
48 practiced
As an SDET and technical lead, craft a concise stakeholder-facing proposal to reduce brittle, over-specified mocks in the test suite for a mission-critical service. Your proposal should include a cost/benefit analysis, a phased technical plan (add integration tests, contract tests, targeted e2e), a rollback plan, and clear metrics to measure success over the next quarter.
MediumTechnical
53 practiced
Design tests to validate circuit-breaker behavior and retry policies in a service that calls external HTTP APIs. Describe how you would use mocks or a local controllable stub server to produce timeouts, slow responses, and HTTP 5xx errors, and how to assert circuit breaker state transitions and retry counts during test execution.
MediumTechnical
58 practiced
As SDET, propose an approach to ensure mocks and stubs stay aligned with real service contracts. Include automation ideas such as consumer-driven contract testing, CI gate verifications, mock generation from schemas, and strategies for handling breaking contract changes across teams.

Unlock Full Question Bank

Get access to hundreds of Mocking, Stubbing, and Test Isolation interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.