Book Deep-Read · Software Engineering at Google · Chapter 11
Software Engineering at Google · Ch 11 · Testing Overview · Adam Bender · 2020
The software behind Google Search changes almost every day, yet you rarely see it suddenly break. This chapter is about one of the reasons: letting machines check the software over and over instead of people (automated testing), and how Google turned that into a company-wide habit.
You'd think tests exist to catch bugs. This chapter says something just as important: they let people dare to change code. In 2005, the team running the web server behind Google Search was at one point shipping releases where more than eight in ten carried a user-visible bug and had to be pulled back. Everyone was nervous about making changes, and work slowed to a crawl. Then the team adopted one rule: every change must come with automatic checks. A year later, emergency fixes had dropped by half, in a year when they were changing more than ever.
The old way was a room of testers clicking through everything by hand. But today's search has to find flights, movie times and images, multiplied by every language, country and device. Nobody can click through all that. Worse, even if every engineer is excellent and makes just one mistake a month, a team of a hundred still produces five new mistakes every working day. Clever people alone don't survive scale.
Google never ordered anyone to write tests. Instead it used new-hire classes, a one-page testing tip posted in restroom stalls every week, and a leaderboard that ranked teams, until "testing is everyone's job" became the default culture. The honest cost: writing tests takes time, a big pile of tests needs looking after, and some things, like whether a search result is actually good, still need human judgment.
Tests aren't only for catching mistakes. They let many people safely change the same code every day.
Want the two separate axes of size and scope, the 80/15/5 mix, the ice cream cone and hourglass anti-patterns, why a one-in-a-thousand flake rate hurts, and why coverage numbers mislead? → Switch to the deep read
You think tests are for catching bugs; this chapter says they are first of all for supporting change. Code that keeps changing for decades in the hands of tens of thousands of engineers can only change safely with fast, deterministic, automated tests. Google's approach: classify tests by resources (size) rather than by name, prefer small and narrow tests, fight flakiness hard, and make testing everyone's job through culture rather than mandate.
Fourth chapter of Part III "Processes", and the overview of the four testing chapters (Ch11–14). It follows Ch10 Documentation (a test is executable documentation) and leads into Ch12 Unit Testing, Ch13 Test Doubles and Ch14 Larger Testing. Real-world counterparts: the test pyramid, CI gates, Bazel's size attribute, and the endless coverage-metric debate.
The chapter opens with Google's own pain: the Google Web Server (GWS), which serves Google Search queries and which the book likens to air traffic control for an airport. In 2005 the project had swollen; releases were getting slower and buggier, engineers lacked confidence in their changes, and they often learned something was wrong only when features broke in production. At one point more than 80% of production pushes contained user-affecting bugs that had to be rolled back.
The GWS tech lead then required that every new change include tests, and that those tests run continuously. Within a year, emergency pushes dropped by half, even as the project saw a record number of changes every quarter. Today GWS has tens of thousands of tests and releases almost daily.
The key lesson the chapter draws: you can't rely on programmer ability alone to avoid defects. The book's arithmetic: a 100-person team where each engineer writes just one bug a month still produces five new bugs every workday, and in a complex system fixing one bug often causes another. Tests turn individual wisdom into a shared team asset: one person writes a test and everyone benefits, while debugging makes someone pay the full cost again every time a bug appears. Leave it unsolved, and once code size and release frequency climb, manual validation can't keep up: the team either slows down or ships bugs to users.
Automated testing is three activities: writing tests, running tests, and reacting to failures. Expressed as code instead of manual steps, tests can run on every change, thousands of times a day, and switching browsers or UI languages is just a configuration change. But the chapter stresses that the third step decides whether tests are worth anything: letting failing tests pile up quickly defeats their whole value. Teams that fix a broken test within minutes keep confidence high and isolate failures fast.
The benefits listed go beyond "less debugging": more confidence in changes, refactors that need no test edits; tests as executable documentation that turn red first when requirements change; simpler reviews, since the reviewer can check that each edge case has a passing test; code that is hard to test usually has a design problem (too many responsibilities, unwieldy dependencies); and finally fast, high-quality releases.
Early on, Google noticed engineers favored large, system-scale tests that turned out slow, unreliable and hard to debug, so teams drifted toward smaller and smaller tests. That triggered a debate over what "small" actually means. The chapter's answer splits it into two independent dimensions:
Why not just say "unit" and "integration"? Because the two qualities Google wants most are speed and determinism, and those are driven by resources, not scope. Classifying by resources also lets infrastructure enforce it: the book notes that Google runs Java tests under a custom security manager, so a test tagged small fails outright if it tries to open a network connection.
Small tests must run in a single process (in many languages, a single thread), may not sleep, do I/O or make any blocking call, so no network and no disk (the exception: a hermetic in-memory filesystem). Need a database? Use a test double. These limits shut out the two biggest sources of slowness and nondeterminism, so the test runs as fast as the CPU allows.
Medium tests may span processes, use threads and make blocking calls; they can start a real database or drive a real browser through WebDriver. The one remaining rule: network calls only to localhost. The book calls cross-machine networking "far and away the biggest source of slowness and nondeterminism in most systems", so blocking it still gives some protection, but "the safety is off" and engineers must be more careful.
Large tests drop the localhost limit and may span machines. Google reserves them mostly for full-system end-to-end tests that validate configuration more than code, and for legacy components that can't use doubles, and often isolates them to run only during build and release so they don't slow daily work. (A footnote admits Google internally has a fourth size, enormous.)
Requirements shared by every size: hermetic, carrying everything needed to set up, run and tear down its environment, with no reliance on test order or a shared database; and obvious upon inspection, because there are no tests for tests, only human review, which is why conditionals and loops in tests are strongly discouraged.
A flaky test passes and fails with no code change. The chapter's arithmetic is blunt: if each test has just a 0.1% chance of failing when it shouldn't and you run 10,000 tests a day, you'll investigate 10 false failures a day. Automatic reruns help, effectively trading CPU cycles for engineer time, but only postpone the root-cause fix. The deeper damage is trust: in the book's experience, as flakiness approaches 1%, tests begin to lose value, engineers stop reacting to failures, and the suite becomes decoration. Google's own rate hovers around 0.15%, which at its scale still means thousands of flakes a day, so it actively invests engineering time to fix them. The usual culprits are nondeterminism in the tests themselves: clock time, thread scheduling, network latency.
Google also pushes for narrow scope. The rough target, by test count, is about 80% unit, 15% integration, 5% end-to-end: Google's take on Mike Cohn's test pyramid (every team's mix differs a little). Unit tests make a great base: fast, stable, and failures are nearly free to diagnose. Larger tests are sanity checks as the product takes shape, not the primary way to catch bugs.
What should you test? Everything you don't want to break: performance, correctness, accessibility, security, and how the system handles failure. Google calls this the Beyoncé Rule: "If you liked it, then you shoulda put a test on it." Infrastructure teams that make changes across the whole codebase invoke it often: if an unrelated infrastructure change passes all your tests but still breaks your product, fixing it and adding the missing tests is on you. Testing for failure means simulating exceptions in unit tests, injecting RPC errors and latency in integration and end-to-end tests, and, one level up, Chaos Engineering.
Code coverage only measures that a line was executed, not that its result was checked; a few tests can produce a big number. The chapter recommends measuring coverage from small tests only, to avoid inflation from large ones. The subtler trap: set an 80% bar and engineers treat the floor as a ceiling, with changes landing at exactly 80%. Better questions: are you confident everything customers expect will work? Will you catch breaking changes in your dependencies? Are your tests stable?
Before 2005, testing at Google was "closer to a curiosity than a disciplined practice". After GWS, a band of volunteers, the Testing Grouplet, changed the culture with three moves: an hour on testing in new-hire orientation, so new hires carried it into their teams as normal practice; Test Certified, five levels each reachable within a quarter, with a dashboard showing every team's level, which had helped more than 1,500 projects by the time the automated Project Health (pH) replaced it in 2015; and Testing on the Toilet, one-page testing tips posted in restroom stalls since April 2006 and still distributed almost weekly. They considered asking leadership for a mandate but judged it counter to Google's culture, and chose to let success spread. Today every change is expected to include both feature code and tests, and blocking a change for missing tests is perfectly reasonable.
Table 1 · Three test sizes: what's allowed, what it costs
| Size | Allowed | Bazel default timeout | Honest cost | Good for |
|---|---|---|---|---|
| Small | One process (often one thread); no sleep / I/O / blocking | 60 s | Relies on doubles, which can drift from real deps | Business logic, edge cases; the default choice |
| Medium | Multi-process, blocking calls, localhost only | 300 s | Depends on the OS and third-party processes; flakiness creeps in | Real DB, real browser, service-storage seams |
| Large | Spans machines | 900 s | Slow, flaky, hard to debug; often moved out of daily workflow | Full-system config checks, legacy parts that can't use doubles |
Table 2 · Suite shapes: how they happen, what they cost
| Shape | Typical cause | Cost |
|---|---|---|
| Pyramid (~80/15/5) | Narrow unit tests first, integration tests at the seams | Unit tests can't verify contracts between teams; the integration layer has to cover that |
| Ice cream cone | A prototype rushed to production, testing debt never repaid | Slow, unreliable, painful; the worst shape |
| Hourglass | Tight coupling; dependencies hard to instantiate alone | Problems a middle layer would catch fall to end-to-end tests: caught late, hard to trace |
The rule of thumb: for any piece of functionality, write the smallest test that can validate it. The mix serves two goals, engineering productivity and product confidence. Lean on integration tests and suites run slower but catch more cross-component issues; lean on unit tests and they finish fast but can't see contracts between components. In the book's words, a good suite is a blend suited to local architectural and organizational realities; 80/15/5 is only a rough guide.
This classification has been open-sourced as tooling: Bazel (the open-source version of Google's internal Blaze) gives test rules a size attribute (small / medium / large / enormous), and with no explicit timeout it assigns 60 / 300 / 900 / 3600 seconds by size, turning "size is defined by resources" into a build-system constraint. Google's scale explains why these rules are needed: the book cites a monorepo of more than two billion lines of code and close to 25 million lines of change a week, about half from automated systems, with almost no branching and builds always using the latest validated commit. Asked in an interview how you'd design a testing strategy, the strong answer isn't "hit 80% coverage" but "size tests by resources, favor small and narrow, watch the flake rate, and put a test on every behavior you care about".
Industry evidence · publicly verifiable
size: small→60 s, medium→300 s, large→900 s, enormous→3600 s, and it advises setting timeouts as tight as you can without flakiness. bazelbuild/bazel · Test encyclopedia ↗① Tests exist first to support change; GWS went from 80%+ of pushes needing rollback to half the emergency pushes within a year.
② Ability alone doesn't scale: 100 engineers at one bug a month each is five bugs a day; tests turn individual wisdom into a team asset.
③ Write, run, react: letting failures pile up wipes out a suite's value.
④ Size (resources) and scope (code validated) are independent axes; small = one process, medium = one machine, large = many machines, enforced by infrastructure.
⑤ Write the smallest, narrowest test that works; aim roughly for 80% unit / 15% integration / 5% end-to-end; beware the ice cream cone and the hourglass.
⑥ Flakes are costly: 0.1% × 10,000 runs = 10 false failures a day; near 1% trust collapses; Google sits around 0.15%.
⑦ Tests should be hermetic and obvious on inspection, with no conditionals or loops.
⑧ Beyoncé Rule: if you care about it, test it; if someone breaks it and you had no test, it's on you.
⑨ Coverage only says "executed"; judge a suite by behaviors and confidence.
⑩ Culture came from orientation, certification, restroom tips and visible success, not a mandate; judgment and creative testing still need humans.