Scrivio Interview library
ScenarioAdvanced7 min read · updated 12 November 2026

Your API test suite of 2,000 REST Assured tests takes 50 minutes and runs against a shared environment. Releases wait for it. How would you restructure API testing?

I would move most behaviour checks down to in-process tests, MockMvc or slice tests, and keep a small REST Assured suite for full-stack paths. The remaining full-stack tests would run against an ephemeral environment built with Testcontainers instead of a shared one, in parallel with isolated data per test such as unique tenants. Along the way, redundant tests that check the same thing at several levels are deleted, and runtime and flakiness are tracked per test against a time budget for the pipeline, for example ten minutes.

Why this question is asked

A 50 minute suite that every release waits for is a tax on everything the team does. Developers batch changes to avoid waiting, bigger batches fail more often, and when the shared environment is down, nobody can release at all. Interviewers ask this scenario because the obvious answer, 'buy more machines', fixes the least important part of the problem. In this answer, we will diagnose where the time and risk come from, then restructure the suite in four moves, show the effect with concrete numbers, and set up the measurements and budget that stop it from growing back.

1Diagnosing the Suite

Before changing anything, I would look at what the 2,000 tests actually do. A quick analysis usually shows three groups. A large group, often more than half, checks behaviour that lives in one service: validation messages, status codes for bad input, field mappings, business rules for different inputs. These do not need a real server or a deployed environment; they are using an expensive tool for a cheap question. A middle group checks real integration: security, the real JSON setup, persistence, calls between components. And a small group checks journeys that cross the whole system, such as placing an order and seeing it in the order history.

The run itself also tells a story. At 50 minutes for 2,000 tests, the average is 1.5 seconds per test, and they probably run one at a time because they share data in the shared environment. Some of that time is network round trips to the shared environment, and some is waiting for asynchronous work with sleeps. The shared environment also adds failures that have nothing to do with the change: another team's deployment, someone else's test data, an outage.

2Move 1: Push Behaviour Checks Down to In-Process Tests

The biggest win is moving the first group down. A check such as 'posting an order with qty 0 returns 400 with a field error' runs in a few milliseconds with @WebMvcTest and MockMvc, where the service is mocked, instead of 1.5 seconds through the whole stack. Business rules move further down into plain unit tests of the domain code.

Java
// Before: a REST Assured test against the shared environment, about 1.5 s
given().baseUri(STAGING).contentType(JSON).body("{\"sku\":\"A1\",\"qty\":0}")
.when().post("/orders").then().statusCode(400);
// After: a web slice test, a few ms, no server and no shared data
@WebMvcTest(OrderController.class)
class OrderValidationTest {
@Autowired MockMvcTester mvc;
@MockitoBean OrderService service;
@Test
void rejectsZeroQuantity() {
assertThat(mvc.post().uri("/orders").contentType(APPLICATION_JSON).content("{\"sku\":\"A1\",\"qty\":0}"))
.hasStatus(HttpStatus.BAD_REQUEST);
}
}

This is not about lowering quality. The in-process test checks exactly the same behaviour, with less that can go wrong for unrelated reasons. What remains in REST Assured are the tests whose value comes from the full stack.

3Move 2: Run Full-Stack Tests Against Ephemeral Environments

The tests that stay full-stack should not depend on a shared environment. Instead, each pipeline run starts the service with its real dependencies in containers, PostgreSQL, Kafka and WireMock stubs for other services, using Testcontainers and @SpringBootTest(webEnvironment = RANDOM_PORT), or a small docker compose setup for multi-service journeys. The environment exists only for that run and is thrown away afterwards.

This removes a whole class of failures: no other team can deploy into our environment or change our data, and two pipelines never fight over the same resources. It also lets developers run the same full-stack suite on a laptop before pushing. Calls to other teams' services are covered by stubs plus contract tests, so the ephemeral environment does not need the whole company in it.

4Move 3: Parallelise With Isolated Data

Once tests do not share an environment, they can run in parallel, but only if they do not share data. Each test creates its own tenant or customer with a unique id, queries and asserts only on that, and never truncates tables. With that in place, JUnit's parallel execution or several build forks can run the full-stack tests concurrently. Going from one at a time to eight in parallel turns a 10 minute full-stack suite into well under 2 minutes, provided the tests are independent.

5Move 4: Delete Redundant Tests

A suite that grew for years usually checks the same thing many times: the same validation rule through the API, through the service and through a unit test; the same happy path in twenty slightly different REST Assured tests. While moving tests down, we delete the duplicates. A useful rule is that each behaviour has one test at the lowest level that can check it, plus at most one full-stack test if the behaviour depends on the whole stack.

Deleting tests makes people nervous, so it helps to be systematic. Coverage reports before and after show that the code is still covered, and mutation testing on a sample can show the remaining tests still catch faults. Every deletion goes through review like any other change.

The API test suite before and after
BeforeAfter
REST Assured full-stack tests2,000about 150
In-process slice and unit testsfewabout 1,500 (many merged or deleted)
EnvironmentShared, long-livedEphemeral, per pipeline run
ExecutionSequentialParallel, isolated tenants
Pipeline time for API tests50 minutesunder 10 minutes
Failures unrelated to the changeFrequentRare, tracked per test

Put together, the four moves change the shape of the suite dramatically. The numbers below are typical for this kind of restructuring and give a realistic target.

6Keeping It Fast: Budgets and Per-Test Tracking

Suites grow back unless someone watches them. I would track the runtime and the flake rate of every test, collected from CI reports, and set a time budget for the pipeline stage, for example ten minutes for API tests. When the stage approaches the budget, the slowest and flakiest tests are reviewed first, and a new full-stack test needs a short justification of why a lower-level test would not do.

I would also measure the effect on delivery, because that is the real goal: how long a change waits from merge to release, and how often a release is blocked by test failures that were not caused by the change. Showing those numbers improving is what keeps the team and management committed when the next test is tempting to write at the top level.

7Follow-up questions

Would you keep any tests against the shared environment?

A handful of smoke tests after deployment, checking that the real deployed services can talk to each other with real networking and security. They run after the release, or as a final check, and do not block every merge. Everything else moves to cheaper and more reliable levels.

How do you get QA engineers who wrote the REST Assured suite on board?

By involving them in the classification and the redesign. Their tests encode valuable knowledge about what matters, and that knowledge moves to the lower-level tests and to the smaller full-stack suite. Many QA engineers welcome the change, because they spend less time investigating failures caused by the shared environment.

Can you speed it up just by parallelising the current suite?

Only partly. Against a shared environment, parallel tests collide on data and add load to an environment other teams depend on. Parallelising works once the data is isolated and the environment is ephemeral, which is why it is the third move, not the first.

8Conclusion

In this answer, we restructured a slow API suite in four moves. Most behaviour checks moved down to in-process slice and unit tests, leaving a small REST Assured suite for full-stack paths. That suite runs against ephemeral environments built with Testcontainers rather than a shared one, in parallel with isolated data per test. Redundant tests were deleted, each behaviour keeping one test at the lowest useful level. Finally, per-test runtime and flakiness are tracked against a pipeline time budget, and release lead time shows whether the change paid off.

What to say in the interviewAbout 90 seconds aloud

Open with

I'd first look at what the 2,000 tests check. Typically more than half test behaviour inside one service, like validation, status codes and mapping rules, through the whole stack against a shared environment, at about 1.5 seconds each, sequentially.

Then, if they want more

So I'd do four things. First, push those checks down: validation and error responses become @WebMvcTest tests with MockMvc or MockMvcTester and a mocked service, taking milliseconds, and business rules become plain unit tests. I'd keep a small REST Assured suite, maybe 150 tests, for what really needs the full stack: security, the real JSON setup, persistence and key journeys.

Second, stop using the shared environment as a gate. Those full-stack tests run against an ephemeral environment per pipeline, with the service on a random port and PostgreSQL, Kafka and WireMock in Testcontainers, and other teams' APIs covered by stubs and contract tests.

Third, parallelise, but only after isolating data: every test creates its own tenant with a unique id and asserts only on that. Fourth, delete redundant tests, keeping one test per behaviour at the lowest level that can check it, with coverage and mutation testing to show we didn't lose anything.

Then I'd track runtime and flake rate per test, set a budget like ten minutes for the stage, and measure release lead time to show the effect. I'd keep only a few smoke tests against the real deployed environment after release.

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 API test suite of 2,000 REST Assured tests takes 50 minutes and runs against a...": https://scrivio-interview-library.netlify.app/java/integration-testing/13de559d0b/