Overview

5 Testing as waste prevention

Testing is valuable only when it protects customer, business, or developer outcomes. The text argues that test suites should be treated like production systems: they can prevent defects and rework, but they can also create waste through overproduction, waiting, motion, overprocessing, inventory, and wasted skill. A useful test is fast, stable, and behavior-focused; a wasteful one is brittle, slow, or tied to internal implementation details that do not matter to users. The core judgment is not how many tests exist, but whether they reduce real risk and preserve flow.

The chapter emphasizes that the cheapest defects are the ones prevented before code is written, which is why test-first practices are framed as upstream control rather than downstream inspection. Tests should define correct behavior before implementation, giving design a constraint to satisfy and helping code generation tools produce safer outcomes. Test layers should also be arranged by risk: unit tests for frequent business-rule failures, integration tests for boundary and contract risk, and a small number of end-to-end tests for critical customer journeys. When test layers are aligned to impact, they stop defects earlier and shorten feedback loops.

Flaky tests and inflated coverage are presented as two major sources of false confidence. Flaky tests undermine trust, encourage reruns and batching, and lengthen cycle time by making feedback unreliable; they should be treated as defects in the delivery system itself. Coverage can reveal blind spots, but it does not prove value protection, because a high percentage can still miss important business contracts and failure modes. The text closes by urging teams to use automation and coverage selectively, to eliminate tests that add noise, and to make small, measurable improvements that reduce waste and restore confidence in the flow of work.

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.

FAQ

What is the main purpose of testing in a Lean software system?Testing’s main purpose is to protect value, not just code. A test is worth keeping only if it reduces real risk for customers, the business, or developers. If it does not prevent meaningful defects or improve flow, it creates waste instead of value.
How can I tell whether a test is value-adding or wasteful?Use three questions: does it prevent a defect that would reach users, does it fail only when behavior breaks, and can it run fast enough to execute on every commit? If the answer is no, especially if it pins implementation details, it is likely wasteful.
Why are tests that assert implementation details considered harmful?They break when internals change even if user behavior stays correct. That creates rework during safe refactoring, slows change, and turns tests into structure policing rather than protection of business outcomes.
What is the difference between test-first and test-after approaches?Test-first introduces a behavior constraint before implementation, which helps prevent defects upstream at the cheapest point. Test-after validates whatever was built, which often detects defects later and makes rework more expensive.
How should test layers be structured around risk?Put the fastest, most deterministic tests closest to the highest-impact risks. Unit tests should protect business logic, integration tests should protect boundaries like databases and APIs, and end-to-end tests should be reserved for the most critical user journeys.
Why are flaky tests treated as flow-blocking defects?A flaky test makes feedback unreliable. That causes reruns, batching, ignored red builds, and distrust in the suite. In Lean terms, it blocks flow and creates waste in time, motion, overprocessing, and delayed defect discovery.
What kind of waste does a flaky test create?It creates waiting through reruns, motion through context switching, overprocessing through retries and sleeps, inventory through unresolved broken tests, defects when real failures get dismissed, and skills waste when engineers debug nondeterminism instead of improving design.
Why can AI-generated tests increase waste?AI often generates structural tests that cover branches, null checks, and exceptions without understanding business value. That can inflate coverage while creating brittle tests that fail during safe refactoring and add maintenance cost without reducing risk.
What should coverage metrics be used for?Coverage should expose unexplored execution paths in high-impact areas, not be used as proof of quality. A green coverage report does not mean the right risks are protected, so it should be combined with a value lens and contract-based assertions.
When should automation not be added?Do not automate checks that mostly verify implementation details, duplicate cheaper protection already in place, or introduce long runtimes and noisy failures. Automate only when the check reduces more waste than it creates and protects a meaningful contract or risk.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build High Value Software Systems ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build High Value Software Systems ebook for free