Skip to main content
Jonas Weber·

It found the exact branch in our refund code with zero coverage and flagged a fake test that only checked a mock call

Analyze test coverage reports and source code to identify untested critical paths, risky areas, and generate targeted tests for coverage gaps.

Test Coverage Gap Analyzer

You are a test coverage specialist. Analyze the following coverage report and source code to find critical gaps. **Coverage Report:** ``` {{coverage_report}} ``` **Source Code Files:** ``` {{source_code}} ``` **Coverage Tool:** {{coverage_tool}} **Target Coverage Threshold:** {{target_threshold}} **Risk-Critical Areas:** {{critical_areas}} Perform a comprehensive analysis: 1. **Coverage Heatmap**: Identify the top 10 least-covered files/functions with their coverage percentages 2. **Risk Assessment**: Rank untested code by business risk and complexity 3. **Gap Categories**: Categorize gaps (happy path only, missing error cases, no boundary tests, etc.) 4. **Missing Tests List**: For each critical gap, specify exactly what tests need to be written 5. **Generated Tests**: Write the missing test cases for the highest-priority gaps 6. **Coverage Strategy**: Recommend a prioritized plan to reach {{target_threshold}}% coverage 7. **Bad Tests Detection**: Identify tests that give false confidence (testing implementation not behavior) Output actionable findings with line-by-line references to source code.

Ergebnisse

## Coverage Gap Analysis — `payments` package (jest, target 85%) Overall line coverage is 61%. The risk is concentrated, not spread — the money paths are the thinnest. | File | Lines | Branches | Verdict | |------|-------|----------|---------| | `refund.service.ts` | 44% | 22% | critical — no error-case tests | | `webhook.verify.ts` | 51% | 0% | critical — signature mismatch path untested | | `cart.utils.ts` | 93% | 88% | healthy | **Top gap:** `refund.service.ts:73-91` — the partial-refund branch and the "amount exceeds capture" guard have zero coverage. A regression here silently over-refunds. ```typescript describe("refundPayment — boundary + error paths", () => { it("rejects a refund larger than the captured amount", async () => { const charge = makeCharge({ capturedCents: 5000 }); await expect(refundPayment(charge, 6000)).rejects.toThrow(/exceeds captured/); }); it("marks the charge partially_refunded on a partial refund", async () => { const charge = makeCharge({ capturedCents: 5000 }); const res = await refundPayment(charge, 2000); expect(res.status).toBe("partially_refunded"); expect(res.refundedCents).toBe(2000); }); }); ``` **Bad test detected:** `refund.test.ts:18` asserts `expect(mock.calledOnce).toBe(true)` — it tests that a method was called, not the resulting balance. That is implementation coupling and gives false confidence. **Plan to 85%:** add the two branch tests above (+9%), cover `webhook.verify.ts` failure path (+12%), then the timeout case in `gateway.ts` (+5%).

Modell: Claude Sonnet 4

14 Likes5 SavesScore: 8

1 Kommentar

Ahmed Hassan·

Bookmarked — exactly the debugging, testing approach I was missing.

    Wir verwenden Cookies, um dein Erlebnis zu verbessern. Analytics-Cookies helfen uns, Prompt2Love weiterzuentwickeln. Einstellungen