A real-world escaped defect despite high coverage: diagnosing why the suite missed it (mocked boundaries, missing contract and integration tests, weak assertions), the incident response, and the test strategy changes that followed.
A strong answer picks a real bug where coverage looked good but a boundary wasn't tested, for example a JSON contract change: a global JsonStringEnumConverter was added, enums started serialising as strings instead of numbers, and an older mobile app version crashed on parse. Every line was covered, but tests mocked the HTTP layer or deserialised with the same options as the server, so nothing compared the wire format with what clients expect. Then explain the response: roll back, add a failing regression test, and change the strategy: response snapshot tests with Verify, an OpenAPI diff in CI, and contract tests with the main clients. The lesson to land: coverage measures execution, not whether the right things were asserted at the right boundary.
"The clearest example I have is a contract bug. At [company] we had a .NET API serving a mobile app and [two] partner integrations, with about 90% line coverage and a coverage gate in CI.
A developer added
JsonStringEnumConverterglobally inProgram.csso new enums would read nicely in the API docs. Every test passed. In production,OrderStatuswent from2to\"Shipped\"on the wire, and [the Android app versions older than 4.2], which parsed it as an integer, crashed on the order history screen. We saw a spike in crash reports and a [12%] drop in successful order-history loads within [40 minutes]. I led the response: we rolled back via slot swap in about [ten] minutes, then looked at why 90% coverage hadn't helped. The answer was that coverage measured execution, not the contract. Our controller tests called handlers directly, and the few HTTP tests deserialised responses with the sameJsonSerializerOptionsas the server, so a round trip always succeeded. Nothing compared the wire format against what clients actually expected.We fixed it properly in three steps. First, a regression test that asserted the raw JSON for that endpoint and failed on the bad build. Second, response snapshot tests with Verify for every public endpoint, so any change to the wire format is a visible diff in the PR. Third, an OpenAPI diff with oasdiff in CI that fails on breaking changes, and consumer-driven contract tests with the mobile team. [Result: no client-breaking contract changes in the following year.] The mistake I see is treating an incident like this as 'add one more unit test'. The real fix is adding the missing type of test at the boundary that failed."
| Gap | Why coverage didn't help |
|---|---|
| Handlers tested directly, not over HTTP | Serialisation never ran in the test |
| HTTP tests round-tripped with server's own options | Server and test agreed with each other, not with clients |
| No assertion on raw JSON shape | Values checked, representation not |
| No contract with consumers | Nobody encoded what the mobile app expected |
| Bug | Missing test |
|---|---|
| EF Core query fine on in-memory provider, fails on SQL Server | Integration test on a real database |
DateTime.Now vs UTC around AEST/AEDT daylight saving change |
Tests with FakeTimeProvider and time-zone cases |
| Missing DI registration for a new handler | WebApplicationFactory test per endpoint |
| Config key renamed, works locally from user secrets | Options validation with ValidateOnStart plus smoke tests |
| Tests with no meaningful assertions | Mutation testing (Stryker.NET) |
After adding Verify snapshots for [140] public endpoints and oasdiff in CI, the next quarter's PRs surfaced [six] unintended contract changes, all caught before merge. CI time rose by about 40 seconds.
Checks ownership, root-cause thinking about test gaps, and whether the candidate improves the system rather than patching one case.
Green flags
Red flags
line coverage = lines executed during tests / total lines
branch coverage = branches taken / total branches
Neither says anything about assertions or about the environment the code ran in. A line that runs under a mock of the database is covered, but the SQL it would generate is not tested.
In most incident reviews, escaped bugs cluster at boundaries:
client <-> [serialisation] <-> API <-> [DI / config] <-> handler <-> [EF Core / SQL] <-> DB
|
[HTTP client] <-> third party
|
[clock / time zone]
Unit tests replace every bracketed boundary with a double, so they can't catch bugs that live there. That is why boundary tests (integration, contract, snapshot) give more protection per test for APIs.
Three complementary techniques:
| Technique | What it catches | Tool |
|---|---|---|
| Response snapshot | Any change to JSON output | Verify (VerifyJson) |
| OpenAPI diff | Breaking schema changes (removed fields, type changes) | oasdiff, build-time OpenAPI generation |
| Consumer-driven contract | Changes to what a specific consumer reads | Pact (PactNet) |
Snapshot tests are cheapest to add; contract tests carry the most meaning because consumers define them.
Ask "which test should have caught this, and why didn't it exist?" rather than "who broke it?". The output is a change to the system (tests, gates, analysers), not to a person.
JsonSerializerOptions changes in Program.cs for extra review.JsonStringEnumConverter to an API and see which of your tests fail. If none, you have this gap.oasdiff breaking between two commits.The regression test that failed on the bad build, and the snapshot test added for every public endpoint:
namespace Orders.Tests.Contracts;
using System.Text.Json;
using Microsoft.AspNetCore.Mvc.Testing;
using VerifyXunit;
using Xunit;
public sealed class OrderHistoryWireFormatTests(WebApplicationFactory<Program> factory)
: IClassFixture<WebApplicationFactory<Program>>
{
[Fact]
public async Task Order_status_is_serialised_as_a_number_for_existing_clients()
{
var ct = TestContext.Current.CancellationToken;
var client = factory.CreateClient();
// Read raw JSON: never deserialise with the server's own options here.
var json = await client.GetStringAsync("/orders/history?customerId=demo", ct);
using var doc = JsonDocument.Parse(json);
var status = doc.RootElement[0].GetProperty("status");
Assert.Equal(JsonValueKind.Number, status.ValueKind);
}
[Fact]
public async Task Order_history_response_shape_is_stable()
{
var json = await factory.CreateClient()
.GetStringAsync("/orders/history?customerId=demo", TestContext.Current.CancellationToken);
// Any change to names, casing, types or enum representation shows as a diff.
await VerifyJson(json).ScrubMember("placedAtUtc");
}
}
# CI: fail on breaking OpenAPI changes compared with main
oasdiff breaking origin-main/openapi.json artifacts/openapi.json --fail-on ERR
JsonSerializerOptions. Why it is wrong: round trips always succeed, so wire changes are invisible. Instead: assert raw JSON or snapshot it.Interviewers ask this to see whether you understand the difference between executing code and verifying behaviour, and whether you respond to incidents by improving the system. The best stories show a bug at a boundary, a crisp diagnosis of why the suite couldn't see it, and a change of strategy that covers the whole class of bug, with a measurable result.
| Response to the escape | When it fits | Cost | When not to |
|---|---|---|---|
| One regression test | Always, as step one | Minutes | As the only change |
| New test type across the codebase (snapshot, contract, integration) | Boundary bugs | Days | Pure logic bugs already well covered |
| Mutation testing | Bugs that slipped past weak assertions | CI time | Code that is mostly I/O |
| Raise coverage threshold | Rarely | Low | When coverage was already high |
Afterwards, measure recurrence of that bug class and how many PRs the new guard catches; that's your evidence the change was worth it.
Code coverage tells you which lines ran during tests, not whether any test would notice if they were wrong. A test with no assertions still gives coverage. Mutation testing measures that directly: a tool makes small changes to your code, called mutants (> to >=, + to -, true to false, removing a statement), runs the tests against each, and expects at least one test to fail. A failing test kills the mutant; if all tests pass, the mutant survived, which shows a gap. Stryker.NET does this for C# via dotnet stryker and reports a mutation score with build-breaking thresholds. The trade-off is run time: it re-runs tests many times, so you scope it to core logic and use incremental --since runs.
I make the committed build-time spec the contract and gate pull requests on it:
oasdiff breaking compares the PR's spec with main and the last released spec, and fails on removed paths or properties, new required request fields, narrowed enums or changed types.AddOpenApi("v1"), AddOpenApi("v2")), so breaking changes go into a new version while v1 stays frozen.The trade-off: CI becomes stricter and occasionally needs a deliberate override, but breaking changes become explicit decisions instead of production incidents.
A consumer-driven contract test checks one consumer-provider pair in isolation. The consumer's tests run against a Pact mock and record what it actually uses; the provider replays those expectations against its real code (dependencies stubbed) in its own CI. Because the provider must keep passing every consumer's contract, it can evolve and version its API without silently breaking anyone, which preserves team autonomy.
An end-to-end test deploys many services together and drives a real user journey. It catches wiring, configuration and infrastructure problems contract tests can't, but it needs a shared environment, runs for minutes, fails for unrelated reasons and slows every deployment pipeline that waits on it.
So: a contract test for every consumer-provider pair as the main safety net, and only a handful of end-to-end smoke tests for the few journeys that make money. The trade-off is fast, precise feedback versus realistic but slow, flaky coverage.
How to tell it (STAR)
**S:** Our API had about 90% coverage, but a release crashed the order history screen for [older Android app versions], around [18%] of users. **T:** As [tech lead] I owned the response and the follow-up. **A:** We swapped slots back in about [ten] minutes. I found a global enum converter had changed `status` from a number to a string, and our tests never compared the raw JSON with what clients expected, because they round-tripped with the server's own settings. I added a failing regression test, then snapshot tests for every public endpoint, an OpenAPI breaking-change gate and consumer contracts with the mobile team. **R:** In the next quarter the new checks caught [six] unintended contract changes before merge, and we had [no] client-breaking releases in the following [year].
Last updated 23 Nov 2026.