Scrivio Interview library
LeadershipAdvanced7 min read · updated 12 November 2026

Reactive code in your organisation has frequent production bugs that unit tests did not catch, such as missing subscriptions and blocking calls. What testing standards would you introduce?

I would require StepVerifier or WebTestClient tests for every public reactive method, including its error and empty paths, and run BlockHound in integration tests so blocking calls on event loops fail the build. PublisherProbe tests would assert that fallback branches were or were not subscribed, load tests would reveal event-loop blocking under concurrency, and a review checklist would target the common reactive mistakes, such as subscribe() inside methods and eager evaluation of work that should be deferred.

Background to this question

Reactive bugs have a particular character. Code that forgets to subscribe compiles and runs and simply does nothing. Code that blocks an event loop passes every unit test and only fails under load. Code that builds a fallback eagerly calls a remote service on every request, even when the fallback is not used. Ordinary unit tests with mocks miss all three, which is why an organisation can have high coverage and still frequent production bugs. A lead's job is to set standards that target the actual failure modes. In this answer, we will recap the bugs we see, then go through each standard and the bug it catches, and finish with how to introduce the standards without stalling teams.

1A Quick Recap: The Bugs Unit Tests Miss

The first family is missing subscriptions. A Mono that nobody subscribes to never runs. If a method calls repository.save(order) and ignores the returned Mono, the save never happens. If it calls save(order).subscribe() instead, the save runs detached from the request: errors are lost, the response may be sent before the save finishes, and the transaction context is gone.

The second family is blocking: a JDBC call, a synchronous HTTP client or a Thread.sleep on an event-loop thread. The third is eager evaluation: code that runs at assembly time instead of subscription time, such as switchIfEmpty(callFallbackService()), where callFallbackService() is called immediately to build its argument, on every request. Each family needs a different kind of test.

Java
Mono<Order> place(Order o) {
orders.save(o); // bug: Mono ignored, nothing is saved
audit.record(o).subscribe(); // bug: detached, errors lost
return orders.findById(o.id())
.switchIfEmpty(fallbackService.lookup(o.id())); // bug: lookup() called on every request
}

2Standard 1: StepVerifier or WebTestClient for Every Public Method

Every public method that returns a Mono or Flux gets a StepVerifier test for its success path, its error path and, where it can happen, its empty path. Endpoints get WebTestClient tests that check status, body and error format. The reason this catches missing subscriptions is that the test asserts the effect, not just the return value: after verifying the Mono, it checks that the order exists in the test database or that the mock was called.

Java
StepVerifier.create(service.place(order))
.expectNextMatches(o -> o.id() != null)
.verifyComplete();
StepVerifier.create(orders.findById(order.id()))
.expectNextCount(1)
.verifyComplete(); // fails if save() was never subscribed

Error paths matter as much as success paths, because many reactive bugs are in onErrorResume branches that are never exercised: a fallback that returns Mono.empty() for every error, or an error mapped to the wrong exception. And every chain must end in verify(); a static check for unused StepVerifier results stops tests that silently assert nothing.

3Standard 2: BlockHound in Integration Tests

The integration test suite, the tests that start the application context and call real endpoints with WebTestClient against Testcontainers databases and mock servers, runs with BlockHound installed. Any blocking call on a Netty event loop or a parallel scheduler thread throws BlockingOperationError with a stack trace pointing at the line. The allow list for known safe calls lives in the shared test configuration and changes only through review.

This standard converts the most expensive class of reactive bugs, the ones that only show up as latency spikes under production load, into ordinary test failures on a developer's machine.

4Standard 3: PublisherProbe for Branches

For pipelines with branches, such as switchIfEmpty fallbacks, conditional calls or cache-then-remote logic, tests use PublisherProbe to assert which branch was subscribed. This is the test that catches eager evaluation and wrong-branch bugs, which StepVerifier on the final value cannot see when both branches would produce the same result.

Java
PublisherProbe<Order> remote = PublisherProbe.of(Mono.just(order));
when(fallbackService.lookup(42L)).thenReturn(remote.mono());
when(orders.findById(42L)).thenReturn(Mono.just(order)); // found locally
StepVerifier.create(service.find(42L)).expectNext(order).verifyComplete();
remote.assertWasNotSubscribed(); // passes only if the fallback was deferred
verify(fallbackService, never()).lookup(42L); // fails with the eager version: lookup() was called

Notice the second check. With the eager version, the Mono returned by lookup is not subscribed, so the probe alone would pass, but lookup() itself was called, and in real code that method may start work immediately. The fix is Mono.defer(() -> fallbackService.lookup(id)), and the test should check both that the method was not invoked and that its publisher was not subscribed.

5Standard 4: Load Tests That Reveal Blocking

Some blocking only matters under concurrency: a synchronized block that is fine for one request but serialises a thousand, a connection pool that is too small, a library that blocks only when its cache is cold. So each reactive service has a load test in its pipeline, run at least before releases, at a realistic request rate, measuring p99 latency, event-loop pending tasks and pool usage. A rise in p99 with low CPU is the signature of blocked event loops and fails the run against a threshold the team sets.

6Standard 5: A Review Checklist for Reactive Mistakes

Finally, a short checklist for code review catches what tests may miss. Does any method call subscribe() instead of returning the publisher? Is every returned Mono or Flux used, not ignored? Is work that should be lazy wrapped in Mono.defer or fromCallable? Are blocking calls isolated on boundedElastic? Is onErrorResume limited to specific exceptions? Is block() absent from production code? Static analysis can enforce some of these automatically, for example a rule against subscribe() and block() outside configuration and tests.

Each standard and the bug it catches
StandardCatchesWhere it runs
StepVerifier and WebTestClientlost subscriptions, wrong errorsevery build
BlockHoundblocking on event loopsintegration tests
PublisherProbewrong branch, eager fallbacksunit tests
Load testsblocking under concurrency, pool limitsbefore release
Review checklist and static rulessubscribe(), block(), untyped fallbacksevery pull request

7Introducing the Standards Without Stalling Teams

Writing these standards is easy; getting them adopted is the work. I would start with the incidents: show each team the production bugs from the last quarter and which standard would have caught them, so the rules feel earned rather than imposed. The platform team adds BlockHound, test templates and static rules to the shared build, so most of the work is turned on, not written. New code must meet the standards from day one, while existing code is brought up to them when it is touched and for the services with the most incidents first. And we track the result: reactive bug escapes per quarter, which should fall if the standards target the right failure modes.

8Follow-up questions

Is requiring tests for every public method too heavy?

It would be for trivial getters, but reactive public methods are where the failure modes live, and most of these tests are short. The standard is about behaviour, success, error and empty, not about coverage numbers. Teams can skip pure delegation methods if a higher-level test covers them.

Why not just ban subscribe() entirely?

Because a few places legitimately subscribe, such as an application startup listener or a fire-and-forget task with its own error handling. A static rule that forbids subscribe() outside an allow list of packages or annotated methods keeps those cases explicit and reviewable.

How do you know the standards are working?

Track reactive-related incidents and bugs found after release, tagged by category, before and after the standards. If blocking incidents disappear but lost subscriptions still occur, the tests are probably asserting return values rather than effects, and the standard needs sharpening.

9Conclusion

In this answer, we built testing standards around the reactive bugs that unit tests miss: missing or detached subscriptions, blocking calls and eager evaluation. StepVerifier and WebTestClient tests for every public reactive method, including error paths and effects, catch lost subscriptions; BlockHound in integration tests catches blocking; PublisherProbe catches wrong branches; load tests catch blocking under concurrency; and a review checklist with static rules catches subscribe() calls and eager fallbacks. We introduced them through incident data and shared tooling, and measured whether bug escapes fell.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start from the bugs we actually have, because reactive bugs fall into a few families: missing or detached subscriptions, blocking on event loops, and eager evaluation, like building a fallback with a method call that runs on every request.

Then, if they want more

Then each standard targets one family. Every public reactive method gets StepVerifier or WebTestClient tests for success, error and empty paths, and the tests check effects, like the row in the test database, not just the returned value, which catches ignored Monos and detached subscribe calls.

Integration tests run with BlockHound installed, so a blocking call on a Netty thread fails the build with a stack trace. For branching logic, PublisherProbe asserts whether a fallback was subscribed, combined with a check that the fallback method was not even called, which catches eager evaluation; the fix is Mono.defer.

Each service has a load test before release that watches p99 latency and event-loop pending tasks, since some blocking only hurts under concurrency. And code review has a short checklist backed by static rules: no subscribe or block in production code outside an allow list, typed onErrorResume, blocking calls on boundedElastic.

To get adoption, I would show teams which past incidents each standard would have caught, ship BlockHound and the rules in the shared build, apply the standards to new code immediately, and track bug escapes to see if they work.

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 "Reactive code in your organisation has frequent production bugs that unit tests did not...": https://scrivio-interview-library.netlify.app/spring-boot/reactive-testing-and-ops/33a97eec4e/