Code coverage measures which lines, branches, or functions tests execute. A high percentage shows broad traversal, not that tests protect important behavior or catch real defects. section 5.7
Use coverage to spot unexplored paths in high-impact code, then check whether tests assert meaningful outcomes. Treat the percentage as a signal, not a measure of risk protected. section 5.7 section 5.9
Payment service
Tests can execute both successful and invalid-payment paths while missing whether a declined payment leaves inventory untouched. An assertion for that contract may barely change the coverage percentage, yet protect meaningful behavior. section 5.7
Listing 5.11 Additional edge case test added
def test_declined_payment_does_not_reserve_inventory():
mock_gateway.decline()
result = service.process(valid_order)
assert result == "failed"
assert not inventory.is_reserved(valid_order)This test checks both the failure result and the inventory contract after a declined payment. section 5.7





















