Book Deep-Read · Software Engineering at Google · Chapter 14
Software Engineering at Google · Ch 14 · Larger Testing · Joseph Graves · 2020
The maps, email and search you use every day are dozens of programs calling each other. Engineers check each small part on its own — but every part can pass and the whole thing can still break once it's put together. This chapter is about how to check the assembled whole without letting those checks grind everyone to a halt.
When a car is built, every bolt and tire is inspected at the factory: that's the "parts check". But nobody hands over a car without a test drive. Was something assembled wrong? Was the spec sheet filled in wrong? Does it shake on the highway? Only driving the whole car tells you. A test drive costs far more than checking a bolt, takes longer, and can be thrown off by weather and traffic — so you can't do one every time you tighten a bolt.
Checking only the parts misses several kinds of trouble: the stand-in for a partner program behaves differently from the real one; the program is fine but its settings file is wrong — Google says that is the number-one cause of its major outages; everything works until millions of people show up at once; and users always find uses nobody imagined. Yet whole-car tests are slow, pass one day and fail the next, and span several teams, so when one breaks nobody knows who should fix it, and it gets abandoned.
Parts checks are the foundation; whole-car tests fill the gaps, each covering a different kind of risk. The key is that every whole-car test has a clear owner and says plainly what broke, or people simply skip it. The honest cost: these tests take money and people to build, need constant upkeep, and get harder to maintain the bigger they are.
Every part passing doesn't mean the car drives: larger tests buy realism, but they must be kept small and owned, or they're just an expensive ornament.
Want the fidelity spectrum, the shapes a system under test can take, how record/replay lets a large test spawn small ones, why A/B diff tests are Google's most common large test, and how to fight slowness and flakiness? → Switch to Deep read
You'd think a larger test is just "a bigger unit test". This chapter says it's a different animal: its one reason to exist is fidelity — covering risks that unit tests are blind to by design. But it is inherently slow, nonhermetic and nondeterministic, so the whole chapter is about one thing: make it as small as possible at sufficient fidelity, and make sure someone owns it.
Part III, "Processes" — the last of the four testing chapters. It follows Ch13 Test Doubles (risks doubles can't cover are covered here with real dependencies) and leads into Ch15 Deprecation. Real-world counterparts: integration and end-to-end tests, staging environments, canaries, chaos engineering — the top of the test pyramid.
Think about how you confirm your own program works: you wrote unit tests, but you probably also run the binary and try it. When the Google Maps API you depend on ships a new version, unit tests won't tell you whether you're still compatible. Unit tests give confidence that each part is right; larger tests give confidence that the whole system works as intended — and, being automated, they scale in ways manual testing can't.
But larger tests break the three properties of a good test: reliable (more infrastructure means more flakiness), fast (Google's large tests default to a 15-minute or 1-hour timeout, and some run for hours or even days), and scalable (they eat resources and collide with each other). Add two organizational problems: ownership — when a test spanning several teams breaks, who fixes it? — and lack of standardization — Ads, Search and Drive build their diff tests on different platforms and frameworks, so during large-scale changes nobody knows how to run them, and they get skipped.
Fidelity is how faithfully a test reflects the real behavior of the system under test. Viewed as an environment, it is a spectrum: a unit test bundles a small piece of code with its test into one runnable unit, as far from production as you can get; production itself has the highest fidelity; in between sit single-process, single-machine, multi-machine and shared staging setups. More fidelity means more cost, and in production, more risk of failure — so the goal is the rung that is just good enough.
Fidelity has a second dimension: whether the test data looks real. Handcrafted data covers a narrow range and carries the author's biases; production data is more faithful, but realistic traffic is hard to create before launch.
Scale amplifies this. The book's arithmetic: replace the user server and the ad server with doubles that are only 10% accurate, and the chance of a bug is 1 − 0.1 × 0.1 = 99% — meaning each additional low-fidelity double multiplies down the odds that everything is right when assembled, and more services make it worse. Yet scale also makes the number of end-to-end scenarios explode combinatorially. The conclusion cuts both ways: use larger tests, but build them in ways that work at scale while keeping fidelity reasonably high.
Almost every large test follows four steps: obtain a system under test → seed test data → perform actions → verify behavior. Each step involves choices.
SUT shapes are judged on two factors: hermeticity (how isolated it is from other users — the more hermetic, the less concurrency and infrastructure flakiness) and fidelity (how closely its config, infrastructure and topology resemble production). The two often directly conflict. The book lists five: single-process, single-machine, multi-machine, shared environments (staging and production), and hybrids — unavoidable at Google, since nobody can run a copy of all of Google's interconnected services, so typically the thing under test runs on its own while its backends are shared.
Why hermetic? Testing in production means the code must reach production first, so the test can't block the release — "the SUT is too late". Shared staging means queuing to "reserve" a time slot, which breaks down as engineers and services multiply. The next step is cloud-isolated or machine-hermetic SUTs. The book also tells of YouTube's Webdriver Torso: test videos auto-uploaded to a public channel became a media mystery — any test data in production may be discovered by users; be ready for it.
Shrink the SUT at painful boundaries: UI tests are notoriously brittle (look-and-feel changes turn them red; async behavior is hard to test), so end-to-end tests spanning frontend and backend multiply maintenance costs. Better to split at the UI/API boundary and drive end-to-end tests through the public API — whether the UI is a browser, CLI, desktop or mobile app. Third-party dependencies are another natural seam: there may be no shared test environment and traffic may cost money, so automated tests shouldn't call them directly. Then swap databases for in-memory ones and drop servers you don't care about, until the SUT fits on one machine — the easiest and most stable integration tests there are.
Even for integration tests, smaller is better: a handful of large tests beats one enormous one. A user journey spanning many systems can become chained tests: several small pairwise integration tests, where one test's output is persisted and used as the next test's input.
Record/replay proxies are Google's most popular answer to "a double of a whole service may not match the real thing": record traffic to external services while running a large test, and replay it when running small ones. The Record mode large test runs continuously post-submit, mainly to produce traffic logs; the Replay mode small test is used in development and presubmit. A matcher decides which recorded response to replay, which makes it much like a stub; if client behavior changes a lot, requests stop matching and must be re-recorded — so recording must be easy, fast and stable. Outside Google, consumer-driven contract tests such as Pact are common: the client writes down "for this input I get this output", and the real service runs the same input/output pair in a real test; Google's heavy use of protocol buffers means it doesn't use these internally.
Data comes in two kinds: seeded data (the SUT's state when the test starts) and test traffic (requests the test sends during execution). Seeding is often orders of magnitude more complex than unit-test setup: a social network's large tests need a realistic enough graph of users and connections to be accepted, and writing straight to the datastore may bypass checks on the real write path. Sources: handcrafted, copied from production, or sampled (minimum data for maximum coverage). Verification also comes in three kinds: manual (regression against a test plan, or exploratory), assertions (search for xyzzy, assert the result contains "Colossal Cave"), and A/B comparison (run two SUTs, send the same data, compare outputs — no predefined expectation; a human judges whether each difference is intended).
Many large tests don't belong in TAP: they're nonhermetic, too flaky or too resource-hungry. Google gives them a separate post-submit continuous build and encourages running them presubmit too, since that feeds back straight to the author. For A/B tests that need diffs blessed by a human, approving the diffs in a UI can be made a code-review requirement; one such test even files release-blocking bugs automatically if code is submitted with unresolved diffs. The truly painful ones run only post-submit and at release, at the cost of bad code landing on trunk first and needing a rollback later.
Speeding up: the best lever is reducing scope, or splitting one large test into two that can run in parallel. Don't wait on asynchronous actions with fixed sleeps; poll frequently (with a timeout) or subscribe to completion events — sleep-based tests all start failing when the fleet running them is overloaded, and reruns add more load, a vicious spiral. Timeouts hardcoded in production code should be made tunable and lowered under test.
Driving out flakiness: start by reducing scope — a hermetic SUT has no multi-user interference; a single-machine SUT has no network or deployment flakiness. Timeouts cut both ways: raising internal timeouts reduces flakiness, lowering them can create it, so find a balance between what users tolerate and what keeps tests stable. Subtler still is graceful degradation: when ads time out, Google simply doesn't show an ad rather than returning a 500 — which to a test looks like broken ad-serving code. Make such failure modes obvious.
Understandable failures: the worst error is "Assertion failed" plus a stack trace. A good one assumes the reader doesn't know the code: "In test X, expected 10 search results but got 1". Across process boundaries a stack trace is useless; produce a trace across the call chain, as Dapper does by tying a single request ID to every log in an RPC chain. And say who to contact.
Ownership: a large test must have a documented owner, or it becomes hard to change, slow to fix, and finally rots. Integration tests within a project belong to the project lead; feature tests across services belong to a "feature owner". Record ownership in a structured way (reuse the monorepo's OWNERS files, or per-test annotations) so a failure can find its owner automatically.
Table 1 · Choosing an SUT: hermeticity and fidelity often pull against each other
| SUT shape | Hermeticity | Fidelity | Cost | Typical use |
|---|---|---|---|---|
| Single process | Highest | Lowest; topology and config unlike production | Cheap; even a small test if single-threaded | Fast functional tests |
| Single machine | High | Medium; ideally uses production launch configs | Medium tests; can share machines with builds and unit tests | Multi-binary integration tests (the book's sweet spot) |
| Multi-machine | Medium | High; like a cloud deployment | Large tests; network and machine flakiness | Load tests, A/B diff tests |
| Shared staging / production | Lowest | Highest | Cheapest since it already exists, but collisions, waiting for the push, and production can hurt users | Exploratory tests, probers, disaster drills |
| Hybrid | Varies | Varies | Run the part under test yourself, share the backends | Google-scale systems that can't be copied whole |
Table 2 · The book's types of larger tests (similar ones merged) and the risks each guards against
| Type | SUT / data / verification | Guards against | Honest cost |
|---|---|---|---|
| Functional tests of one or more binaries (incl. browser and device) | Single-machine hermetic or cloud-isolated / handcrafted / assertions | Real interactions between binaries | UI layer is brittle; async is hard |
| Performance, load, stress | Cloud-isolated / handcrafted or multiplexed from production / metric diffs | Regressions between versions; failing under spikes | Noisy: run both versions on the same machine, or do multiple runs and drop peaks and valleys |
| Deployment configuration tests | Single machine or cloud / no data / passes if it doesn't crash | Config incompatible with the binary | Only a smoke test; don't expect logic checks |
| Exploratory testing, bug bashes | Production or staging / production data / manual | Unanticipated paths, security holes | Human time grows with the system; bugs found must become automated tests |
| A/B diff regression | Two cloud-isolated environments / sampled production traffic / diff | Unanticipated side effects (Hyrum's Law) | Diffs need human approval; noise removal is the main complexity; coverage is hard; two SUTs to maintain |
| Probers and canary analysis | Production / production / assertions + metric diffs | Unhealthy production; a bad release spreading | Users are already affected when caught; writes change production state |
| Disaster recovery and chaos engineering | Production / production + fault injection / manual + metrics | Whether fault-tolerance assumptions hold | Same as above; DiRT is expensive, so it runs infrequently |
| User evaluation | Production / production / manual + metric diffs | Whether a feature is liked; whether a change is better or worse | Only after the fact, judged on aggregate metrics |
Which types to use and how much of each is a test strategy: identify the main risks first, then pick the tests that guard against them (Google has a dedicated "Test Engineer" role for exactly this). And do the math holistically: A/B diff tests save human effort on verification, and production SUTs are cheaper to maintain than hermetic ones — but if manually reconciling diffs costs more than it saves, it stops paying off.
Asked "what's your test strategy?", a good answer isn't "90% unit test coverage" but a list organized by risk: config via deployment-config tests and canaries, load via isolated load tests, migrations via A/B diffs, fault tolerance via chaos drills — plus who owns each and when it runs. Time matters too: if prototype-era manual testing keeps piling up, you get the ice cream cone antipattern, and within days you've created "legacy code" that can only be tested end to end.
Industry evidence · publicly verifiable
① Larger tests exist for fidelity: from single process to production is a spectrum — more real means costlier and riskier; pick the rung that's just good enough.
② Unit tests' five blind spots: unfaithful doubles, configuration, load, unanticipated behavior (Hyrum's Law), the vacuum effect; config changes are Google's top cause of major outages.
③ The costs: slow, nonhermetic, nondeterministic — plus two organizational problems, unclear ownership and no standardization.
④ Four-step anatomy: SUT → data → action → verification; choose the SUT by trading hermeticity against fidelity, which often conflict.
⑤ Shrink at painful boundaries: the UI/API line and third-party dependencies; chained tests split long journeys into pairwise small tests.
⑥ Record/replay: a large test records traffic continuously, small tests replay it; the industry counterpart is contract testing like Pact.
⑦ A/B diff tests are Google's most common large test, catching unanticipated side effects at the cost of human approval and noise removal.
⑧ Into the workflow: a separate post-submit build, presubmit where possible; polling and events instead of sleeps; failures that are readable and traceable.
⑨ Every large test needs an owner recorded in a structured way, or it will rot.