Skip to content
tezvyn:

Propose a multi-sprint strategy to fix an inverted test pyramid

Source: martinfowler.comHardHow cards are made

Propose a multi-sprint strategy to fix an inverted test pyramid
Summary

Refactoring under delivery pressure.

Key points

Audit E2E for redundancy; scaffold unit/integration tests; migrate per sprint, keep critical E2E; gate on fast feedback.

Watch out for

Big-bang rewrites or deleting all E2E without a safety net.

What's really being asked

This question tests whether you can lead a structural refactoring of a test suite without halting delivery. Interviewers want to see that you understand the trade-offs between test granularity, execution speed, and confidence. They are looking for a phased, risk-aware roadmap rather than a theoretical ideal. The core signal is your ability to balance immediate business pressure against long-term engineering health.

The full answer

A strong answer starts with an audit phase to inventory existing end-to-end tests and identify overlapping coverage, slow tests, and flake hotspots. Next, it establishes a safety net by scaffolding unit tests for pure business logic and integration tests for database and service boundaries before any end-to-end tests are removed. Then it proposes a sprint-by-sprint migration where redundant end-to-end scenarios are collapsed into lower layers while a small, critical-path end-to-end set is preserved to validate user journeys. It also restructures the deployment pipeline so unit and integration gates run first and fail fast, with end-to-end tests running later or in parallel. Finally, it includes metrics to track progress such as test execution time per layer, flake rate, and code coverage distribution.

The mistakes people make

Red flags include proposing a big-bang rewrite that stops feature work for multiple sprints, which ignores business reality. Another failure mode is suggesting all end-to-end tests be deleted immediately without verifying that faster layers actually catch the same failures. Vague answers that say simply write more unit tests without a concrete migration plan also signal inexperience. Similarly, ignoring the pipeline structure or pretending that flaky end-to-end tests can be fixed solely by adding retries misses the architectural point.

What usually comes next

Interviewers may ask how you would handle a critical end-to-end test that cannot be replicated at lower layers due to complex third-party integrations. They might also ask how you convince product management to allocate sprint capacity to test refactoring, or how you prevent the pyramid from inverting again six months later. Another common follow-up is what metrics you would use to prove the refactor is working.

A concrete example

Suppose a checkout flow has fifty end-to-end tests covering tax calculation, discount rules, and payment gateway integration. A concrete strategy would be to move tax and discount tests into unit tests using parameterized inputs, move database persistence checks into integration tests with an in-memory database, and retain only three end-to-end tests that verify the full happy path, a payment failure, and a timeout. Over four two-week sprints, the team migrates ten end-to-end tests per sprint while monitoring pipeline duration and defect escape rate. Test suite runtime drops from ninety minutes to twelve minutes, and the critical end-to-end tests become stable enough to gate releases.

Interview question

When leading a multi-sprint refactor of an inverted test pyramid, which sequencing best protects delivery while reducing end-to-end test reliance?

  • a.Immediately delete overlapping end-to-end tests and rely on faster unit tests added afterward to catch any regressions
  • b.Pause feature development for two sprints to rewrite the entire suite from scratch, then switch over all at once
  • c.Audit coverage, scaffold unit and integration tests for the targeted logic, then incrementally migrate redundant end-to-end tests per sprint while preserving a critical-path subsetCorrect
  • d.Keep all existing end-to-end tests, add unit tests for new code only, and reduce flakiness by increasing retry counts in the pipeline
Why?

Scaffolding unit and integration tests before incrementally migrating redundant E2E tests preserves a safety net and avoids halting delivery. Deleting overlapping E2E tests before verifying lower-layer coverage catches the same failures is a common red flag that invites regressions.

Just read this? Test yourself on what you have been reading.

Read the original → martinfowler.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on testing — each one lists the topics its interview covers.

See open roles