5 Testing as waste prevention
Testing is presented as a way to prevent waste, not just to catch defects. A test earns its place only when it protects real customer, business, or developer value, and it becomes harmful when it is brittle, too slow, or tied to implementation details. In that case, testing creates extra work through overproduction, waiting, motion, overprocessing, inventory, and wasted skill, because teams spend time maintaining tests that do not reduce meaningful risk.
The chapter emphasizes writing tests before implementation when possible, so they act as design constraints and catch defects at the source. It also recommends structuring test layers around risk: fast unit tests for business rules and calculations, integration tests for boundaries and collaboration, and a small number of end-to-end tests for critical user journeys. The goal is not maximum coverage, but early and reliable feedback placed where failures would be most costly if they escaped downstream.
Flaky tests and overautomation are treated as serious flow blockers because they distort developer behavior and undermine trust in the build. A flaky test turns red builds into ambiguous signals, encouraging reruns, batching, and avoidance, which lengthens cycle time and hides real problems. AI-generated tests can also inflate coverage without adding protection, so the chapter urges using coverage to reveal risk rather than to create false confidence, and making deliberate choices about what to automate based on whether it truly reduces waste.
Contrast between coding first versus testing after and the impact it has on design and defects.
Comparing the standard testing pyramid with a Lean interpretation of the same structure. The Lean view keeps the same shape but changes the intent.
Cascading view of when and where testing can prevent defects.
Failures become treated as features when they happen with no apparent consequences.
Variability widens cycle time and shifts teams from single-piece flow to batching.
Typical developer flow of code change through to merging.
CI automation as a value stream: aligned pipelines compress flow; overloaded pipelines expand cycle time.
Summary
- Testing is Lean when it prevents rework, not when it increases coverage.
- Unit tests protect business contracts at the smallest economic level.
- Risk determines the test layer; not every path deserves the same protection.
- Flaky tests increase variability, widen cycle time, and break flow.
- Activity ratio exposes where you are waiting versus where you are making real progress.
- Automation aligned with value strengthens the value stream; misaligned automation accumulates waste.
- Coverage reveals executed paths; it does not measure protected risk.
Build High Value Software Systems ebook for free