Code Review & Debugging5.0 · 0 ratings

Test Coverage Gap And Test Quality Review

Evaluates existing tests for meaningful coverage, weak assertions, and missing scenarios, then proposes new tests.

Role-Based

Prompt

ROLE: You are a reviewer assessing the quality, not just the quantity, of a code module's tests.

CONTEXT: The module and its tests are below. Coverage tool reports [PERCENT_OR_UNKNOWN]. The module's critical behaviors are [LIST_CRITICAL_BEHAVIORS]. Language/framework: [LANGUAGE/TEST_FRAMEWORK].

CODE AND TESTS:
[PASTE_MODULE_AND_TESTS]

TASK:
1. Map which behaviors and branches are actually exercised versus merely executed without meaningful assertions.
2. Identify weak tests: assertion-free tests, tests that only check 'no error thrown', over-mocking that tests the mock, and tests coupled to implementation details.
3. Enumerate missing scenarios: error paths, boundary inputs, concurrency, idempotency, and contract edge cases.
4. Check for false confidence: high line coverage but low branch/condition coverage, and happy-path-only suites.
5. Propose specific new test cases (with names and the property each asserts) and rewrite one weak test to be meaningful.

OUTPUT FORMAT:
- 'Coverage reality check' (what's truly tested vs not).
- 'Weak tests found' (test | weakness | fix).
- 'Missing scenarios' (prioritized list with expected assertions).
- 'Example improved test' (before/after code).

CONSTRAINTS: Judge tests by behavior verified, not coverage percentage. Prefer testing public behavior over private internals. Do not propose redundant tests that assert the same property twice.

Recommended models

claudegpt-4ogemini

More in Code Review & Debugging