Overview

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.
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.
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.
Cascading view of when and where testing can prevent defects.
Failures become treated as features when they happen with no apparent consequences.
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.
Variability widens cycle time and shifts teams from single-piece flow to batching.
Typical developer flow of code change through to merging.
Typical developer flow of code change through to merging.
CI automation as a value stream: aligned pipelines compress flow; overloaded pipelines expand cycle time.
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 should prevent waste by catching defects early, protecting customer and business value, and enabling safe change with reliable feedback.
How do value-adding tests differ from wasteful tests?Value-adding tests protect real risk and fail only when behavior breaks, while wasteful tests assert implementation details, create maintenance burden, or slow down delivery without improving outcomes.
Why is writing tests before implementation considered beneficial?Writing tests first defines expected behavior upfront, helps catch defects at the cheapest point, and constrains implementation so errors do not travel downstream.
What is the Lean way to structure test layers?Test layers should reflect risk: unit tests for fast business-rule checks, integration tests for boundaries and collaborations, and a small number of end-to-end tests for critical user journeys.
Why are flaky tests treated as serious defects?Flaky tests are defects in the development system because they make feedback unreliable, encourage reruns and batching, and reduce trust in red builds.
What waste does a flaky test create?A flaky test creates waiting, motion, overprocessing, inventory, and even defects when real problems get dismissed as “just flaky.”
How should teams decide what to automate and what not to automate?Automate checks that detect meaningful risk early, run deterministically, and fail only when contracts break; avoid automating assertions that only pin down internal structure or create extra maintenance.
Why can AI-generated tests increase waste?AI often generates tests for branches and structure rather than business value, which can inflate suite size, slow CI, and make safe refactoring harder without improving protection.
What does code coverage tell you, and what does it not tell you?Coverage shows which code paths ran during tests, but it does not prove that important business contracts, user outcomes, or high-impact risks are protected.
What is the key question to ask when reviewing a test suite?Ask whether each test prevents a defect that would matter to users or the business, whether it fails only when behavior breaks, and whether it runs fast enough to support continuous flow.

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


Close
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 Build High Value Software Systems ebook for free
Close
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 Build High Value Software Systems ebook for free