Description
Mutation-testing-inspired gap analysis: branch inventory, simulation, 3 critical tests.

A passing test suite tells you nothing about quality. It tells you the code behaves as expected—not that it behaves correctly under all conditions. This framework finds the gaps. STEP 1 — BRANCH INVENTORY Enumerate every conditional branch in the source (if/else, switch/case, ternary, &&/|| short-circuit, loop entry/exit, try/catch). Count them: B_total. Map each test to branches it exercises (both true and false paths). Count covered branches: B_covered. Mutation Survival Rate = (B_total - B_covered) / B_total × 100. Exceeding 20% means the suite gives false confidence. STEP 2 — MUTATION SIMULATION For each conditional, mentally apply one mutation and predict if any test catches it: - Invert comparisons: > becomes ≤, === becomes !== - Remove a single line: what happens if it does not execute? - Swap true/false branches: execute the 'if' body when condition is false - Off-by-one: > becomes ≥, < becomes ≤, loop `< limit` becomes `<= limit` - Null/empty injection: input is None, [], {} at this specific point Classify each survivor: MISSING INPUT, MISSING ASSERTION, or DEAD CODE. STEP 3 — CRITICAL GAP Which surviving mutant is most likely in production? Usually an error-handling path never tested because 'it should never happen'. This is precisely what fails first under real load. STEP 4 — PRESCRIPTION Write 3 new tests using Arrange-Act-Assert, each targeting a different category (boundary, error path, integration), prioritizing the critical gap: ```python def test_registration_with_existing_email_returns_conflict(): # Arrange: create user '[email protected]' # Act: register same email # Assert: 409 status, body.email_taken ``` OUTPUT: Mutation Survival Rate, Critical Gap, 3 targeted test specs.

Comments (0)

No comments yet. Be the first!

Rating

0 Rating

Log in to rate

Statistics

Rating 0.0 (0)
Bookmarked 0
Comments 0
The prompt has been copied to the clipboard.