Test Levels and the Test Pyramid Questions

How unit, integration, component, end-to-end and contract tests fit together and where each provides the most value. Covers the test pyramid and the competing shapes proposed against it (the testing trophy and the honeycomb), multi-layer test architecture, contract testing as the seam between services, choosing the right level to catch a given class of defect cheaply, and what to run per commit versus per release. Includes the cost and confidence trade-offs between fast low-level tests and slower, broader system tests. The scope is which level a test belongs at and why. Deciding how much to invest in testing and where to prioritize under time pressure is covered separately.

HardTechnical
107 practiced

Design an experiment, and the metrics you would use, to empirically validate whether a proposed test-pyramid ratio (for example, 70% unit, 20% integration, 10% end-to-end) actually improves delivery cadence and defect detection for your product. Include how you would form control versus experiment groups, the duration and sample size or statistical considerations involved, your success criteria, and how you would account for confounding variables.

EasyTechnical
66 practiced

Explain the differences between unit tests, integration tests, and end-to-end tests. For each level, give two concrete examples (functions, modules, services, or UI flows), state when it should run (on a pull request, at merge, or nightly) and its typical execution speed, and discuss the typical maintenance cost and failure modes. Conclude with the concrete trade-offs between speed, coverage, and flakiness for a web application.

EasyTechnical
54 practiced

You are adding a small new feature to an existing web app: a per-user settings toggle that changes UI behavior. Which tests would you write first, and why? Specify the concrete unit, integration, and end-to-end tests you would create, which tests could reasonably be postponed or executed manually instead, and how you would weigh risk, regression likelihood, and return on investment in that decision.

MediumTechnical
50 practiced

A production bug in a critical API path slipped through despite your integration tests passing. Analyze the possible weaknesses across test-pyramid levels, environment parity, test selection, and CI gating that could explain how this happened, and propose a concrete set of improvements and guardrails to prevent similar escapes.

MediumTechnical
67 practiced

For a payment flow that integrates with a third-party gateway, evaluate the trade-offs of three approaches: (A) end-to-end tests running against the gateway's sandbox, (B) integration tests that mock the gateway's responses, and (C) contract tests verifying the request and response schemas between your service and the gateway. Explain where contract tests sit relative to integration and end-to-end tests and what problem they solve that the other two do not, then recommend which of the three you would run on every pull request versus nightly, and justify your choice by risk and cost.

Unlock Full Question Bank

Get access to all 21 Test Levels and the Test Pyramid interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.