Scrivio Interview library

Test strategy

22 questions in 8 subtopics.

Test pyramid

ConceptFoundations7 min read
What is the test pyramid, and how do Spring Boot slice tests such as @WebMvcTest and @DataJpaTest fit into it?
DesignIntermediate7 min read
Design a test strategy for a Spring Boot order service that talks to PostgreSQL, Kafka and two HTTP APIs.
LeadershipAdvanced7 min read
Your organisation relies on a large, slow end-to-end suite that takes 3 hours and fails often. How would you change the test strategy across teams?

Contract testing

ConceptIntermediate7 min read
What is consumer-driven contract testing, and how do Pact and Spring Cloud Contract differ?
ScenarioAdvanced7 min read
Two teams keep breaking each other's APIs despite integration environments. How would you introduce contract testing across 40 services?
LeadershipPrincipal7 min read
Over several years, your company moved from a shared integration environment to contract tests between 200 services. What did you gain and lose, and how do you keep the contract system healthy?

Mutation testing

ConceptIntermediate7 min read
What is mutation testing, how does PIT work in a Java build, and what does a surviving mutant tell you?
LeadershipAdvanced5 min read
Would you add mutation score as a required quality gate for your organisation? Explain your decision.

Property-based testing

CodingIntermediate7 min read
What is property-based testing? Describe a property-based test with jqwik for a function that serialises and deserialises an Order.
ScenarioAdvanced7 min read
Where would property-based testing add the most value in a payments platform, and where would it not?

Test coverage

ConceptFoundations6 min read
What is the difference between line coverage and branch coverage in JaCoCo, and why is 100 percent coverage not proof of correctness?
ScenarioIntermediate6 min read
Management wants a mandatory 90 percent coverage threshold for all services. How do you respond?
LeadershipPrincipal6 min read
Over many years, what has the industry learned about using code coverage as a management metric?

Testing legacy code

CodingFoundations6 min read
You need to add a feature to this method with no tests:
double price(Order o) {
if (o.items().size() > 10) return o.total() * 0.9;
if (o.customer().isVip()) return o.total() * 0.95;
return o.total();
}
Which tests would you write first, and why?
ScenarioIntermediate7 min read
You must change pricing logic in a 3,000-line legacy class with no tests and static calls to the database. How do you start?
LeadershipPrincipal6 min read
A 15-year-old Java system with little automated testing is critical to the business. How would you plan test investment over several years?

Unit test quality and smells

DebuggingFoundations6 min read
Review this test and name its smells: @Test
void test1() {
OrderService s = new OrderService(repo, clock);
Order o = s.create(req);
assertNotNull(o);
verify(repo).save(any());
Thread.sleep(500);
assertTrue(s.findAll().size() > 0);
}
ScenarioIntermediate6 min read
Your team has 4,000 unit tests, yet bugs keep reaching production and every refactoring breaks hundreds of tests. What is wrong with the test suite and how would you improve it?
LeadershipAdvanced6 min read
How would you raise unit test quality across 25 teams where coverage targets are met but tests catch few defects?

Service virtualization

CodingFoundations6 min read
Using WireMock in a Spring Boot test, stub a payment provider that returns 200 for one card and a 503 with a 2 second delay for another, and point the client at it.
DesignIntermediate6 min read
Your service depends on six external APIs, and the shared test environment is down half the time. How would you use service virtualization in your test strategy, and what are the risks?
ScenarioAdvanced7 min read
Twenty teams each maintain their own stubs for the same core platform APIs, and stubs often disagree with the real behaviour. How do you organise this at the platform level?