Scrivio Interview library
DesignPrincipal6 min read · updated 12 November 2026

Your company spends a large share of its CI budget on test execution. As a senior architect, how do you weigh more parallelism, better test design and test selection against each other?

The three levers buy different things. Parallelism buys speed with more compute and is limited by shared state and environment capacity; better test design, fewer end-to-end tests and more unit and contract tests, lowers both time and cost permanently; and test selection lowers the cost of each change but needs trust and monitoring for escaped defects. I would model the cost in CI minutes, developer wait time and incidents caused by missed defects, and usually choose a mix: shard what is safe, invest steadily in test design, and add selection for the slowest suites.

Why this question is asked

When CI spending becomes a line item that finance asks about, the conversation often jumps to a single answer: buy more runners, or cut tests, or adopt a smart selection tool. Each of those can be right, and each can make things worse if it is chosen alone. Interviewers ask senior architects this question to see whether we can compare options that work on different parts of the problem, using numbers rather than preferences. In this answer, we will build a simple cost model, look at what each lever changes in that model and what it risks, compare them side by side, and then describe the mix we would choose and how we would phase it.

1A Simple Cost Model

Test execution costs money in three ways, and a decision that only looks at one of them goes wrong. The first is compute: CI minutes multiplied by the price per minute. The second is developer wait time: the minutes engineers spend waiting for results, multiplied by how many times a day they wait and by what their time costs. The third is escaped defects: bugs that a test would have caught but did not run or did not exist, which become incidents with their own cost.

Here is an example with round numbers. 300 engineers push 900 pipeline runs a day. Each run uses 400 agent-minutes at 0.01 per minute, so compute costs about 3,600 a day. Each run also makes its author wait 40 minutes, and if half of that wait is truly lost time at 1.00 per minute, wait costs about 18,000 a day. Notice that in this example waiting costs five times more than compute. That is typical, and it is why the cheapest suite is not always the best one.

2Lever 1: More Parallelism

Parallelism means running more tests at the same time, inside one machine with TestNG's parallel settings or across machines with sharding. It cuts wait time almost linearly at first: 400 agent-minutes split across 20 agents is about 20 minutes of wall-clock time instead of 40 across 10. Compute cost stays about the same or rises a little, because each shard pays a fixed overhead for checkout and startup.

Its limits are practical. Tests that share state, such as static fields, fixed ids or one staging database, start failing when they run together, and a shared environment can only serve so many concurrent tests. Beyond that point, more agents add cost without adding speed. So parallelism is the fastest lever to pull, but it rests on test independence, which is a test design property.

3Lever 2: Better Test Design

Test design changes what the suite consists of. A check written as an end-to-end browser test might take 40 seconds and need a full environment; the same rule checked as a unit test takes 5 milliseconds, and the interaction between two services checked as a contract test takes a fraction of a second. Moving most checks down the pyramid, keeping only a few end-to-end journeys, lowers compute and wait time together, and it reduces flakiness, which itself costs reruns.

The downside is that it costs engineering time and pays back slowly. Rewriting 500 end-to-end tests is months of work spread across teams. But it is the only lever that makes the suite permanently cheaper, so it deserves steady investment rather than a one-off project.

4Lever 3: Test Selection

Test selection, also called test impact analysis, runs only the tests that could be affected by a change. Simple versions use the module graph: a change in the billing module runs billing's tests and the tests of modules that depend on it. More advanced versions record which tests executed which code and select by the changed files. Selection can cut the tests per pull request by 70 to 90 percent in a large modular codebase.

The risk is escapes: a dependency the tool does not see, such as configuration, reflection or a database schema change, so a test that should have run does not. Selection therefore needs a safety net and monitoring. We still run the full suite after merge or nightly, and we track how often the full run catches something the selected run missed. If that escape rate stays low, for example under one per hundred merges, trust grows; if not, we tighten the rules.

What each lever changes
LeverCompute costWait timeMain risk
More parallelismSame or slightly higherMuch lower, quicklyShared state, environment limits
Better test designLower, permanentlyLower, slowlyEngineering time, slow payback
Test selectionMuch lower per changeLower per changeEscaped defects if the graph is wrong
Only test design lowers both cost and time permanently, but it is the slowest to deliver.

5The Mix We Would Choose

In most organisations the answer is all three, in a deliberate order. First, shard what is already safe to shard, because it gives quick relief to developers and buys time, and it exposes the tests that are not independent. Second, fund continuous test design work: a target such as moving 20 percent of end-to-end checks to lower layers each quarter, with platform support in the form of Testcontainers setups, contract testing and test-data helpers. Third, add selection for the slowest suites, usually integration and end-to-end, with the full suite after merge as the safety net and the escape rate as the guard.

We would review the model every quarter with real numbers: compute spend, the 90th percentile wait time, and incidents traced to tests that were skipped or missing. If wait time dominates, more parallelism is worth its compute. If compute dominates, selection and design come first. The point is that the choice follows the numbers, and the numbers are visible to everyone involved.

Step throughChoosing the next lever each quarter
  1. Is wait time the largest cost?
    YesAdd shards where tests are independentNoNext question
  2. Are end-to-end tests most of the time?
    YesMove checks down to unit and contract testsNoNext question
  3. Is the escape rate of selection low?
    YesWiden selection to more suitesNoTighten selection rules
  4. Review compute, p90 wait and escapesevery quarter

4 steps in order. Play them, or step through them one at a time.

6Follow-up questions

How do you put a number on developer wait time?

We measure pipeline durations from CI data and count how many runs each engineer waits for. Not every minute of waiting is lost, since people switch to other work, so we apply a conservative factor, for example half. Even with that discount, wait time is usually the largest cost, which makes the case for speed investments easy to explain to finance.

Is test selection safe for regulated systems?

It can be, with the right safety net. We would run the full suite before every release and keep a record of what ran for each change, so auditors can see that every released build passed the complete suite. Selection then only speeds up the feedback on pull requests, without reducing what is verified before release.

When would you deliberately spend more on compute?

When it buys wait time cheaply. If adding ten agents costs 300 a day and saves 300 engineers ten minutes each per day, that is 3,000 minutes of engineering time for 300 of compute, an easy trade. The model makes such decisions straightforward instead of a matter of opinion.

7Conclusion

In this answer, we built a cost model with compute, developer wait time and escaped defects, and saw that waiting usually costs more than compute. Parallelism cuts wait time quickly but rests on independent tests and environment capacity, better test design lowers cost and time permanently but slowly, and test selection cuts work per change but must be monitored for escapes. The usual choice is a phased mix, driven by the numbers and reviewed every quarter.

What to say in the interviewAbout 90 seconds aloud

Open with

I would not pick one lever; I would model the cost first. There are three parts: CI compute, developer wait time, and incidents from defects the tests missed.

Then, if they want more

When you put numbers on it, waiting usually costs several times more than compute, so the cheapest suite is not automatically the best. Then I look at what each lever changes.

More parallelism, sharding across agents or TestNG parallel modes, cuts wait time quickly with roughly the same compute, but it stops working when tests share state or the environment cannot serve more concurrent tests.

Better test design, meaning fewer end-to-end tests and more unit and contract tests, lowers both cost and time permanently, but it costs engineering effort and pays back over months.

Test selection runs only the tests affected by a change, which can cut most of the work per pull request, but it can miss dependencies the tool does not see, so it needs a full run after merge and an escape rate that we monitor.

My usual answer is a mix in order: shard what is already independent for quick relief, fund steady test design work with platform support like Testcontainers and contract tests, and add selection for the slowest suites with the full suite as a safety net.

And I would review compute, p90 wait time and escapes every quarter so the next investment follows the data.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your company spends a large share of its CI budget on test execution. As a senior...": https://scrivio-interview-library.netlify.app/java/testng/55cff1be4b/