Exercise 2: Two Independent Bugs, One Integration Test — Possible Solution ==================================================================== THE SECOND BUG ------------------------------ def apply_discount_dollars_BUGGY(price_dollars, discount_pct): return price_dollars - discount_pct # subtracts the raw percentage number # instead of applying it as a percentage RESULTS ------------------------------ Expected (no bugs): $17.99 One bug (buggy price fn only, correct discount fn): $1.80, PASSES: False Two bugs (buggy price fn AND buggy discount fn together): $-8.00, PASSES: False Both scenarios fail the same single integration test. The test's own pass/fail result and even its printed value give no direct signal about how many distinct faults contributed - "$1.80, wrong" and "$-8.00, wrong" are both just "the total is wrong," with no built-in way to tell from the integration test alone whether one component or several are at fault. WHY THIS WORKS AS AN ANSWER ------------------------------ This confirms the chapter's own warn-box directly: an integration test trades fault-localization precision for broader real-code coverage. Here that tradeoff is made concrete in a new way - it's not just that the test can't say WHICH stage is broken, it can't even say HOW MANY stages are broken. Diagnosing that would require exactly what the chapter's own pyramid argument recommends: falling back to the individual unit tests for calculate_price_in_cents and apply_discount_dollars, each of which would independently and precisely report its own specific fault.