---
name: test-gap-finder
description: Combine coverage data with mutation-testing survivors to produce a ranked list of untested behaviors — the ones most likely to ship bugs.
title: Test Gap Finder
category: code-development
difficulty: advanced
author: admin
icon: 🕳️
input: structured-data
output: markdown
phase: post
domain: code
tags: mutation-testing,code-coverage,test-gap-analysis,quality-assurance,ast-analysis,assertion-validation,test-prioritization,coverage-report,bug-prevention,behavior-clustering,lcov,stryker
best_for:
  - Identifying untested code paths in high-coverage codebases
  - Prioritizing test-writing effort by ROI
  - Post-mutation-testing analysis and reporting
  - Improving assertion density without inflating line-count metrics
---

## Description

Consumes a coverage report plus a mutation-testing run and emits a ranked list of code paths that are nominally 'covered' but have weak or no assertions. Each gap entry includes the file, the exact uncovered behavior, and a suggested test case description (not generated code — just the description, to avoid overfitting).

## Why it works

Line coverage overstates quality — a test can execute a line without asserting on its result, leaving a mutation-survivor that proves the behavior is untested. Combining the two datasets reveals the gap: high execution coverage plus high mutation survival equals 'we run this code but don't check the result.' That is the highest-ROI gap to close.

## How it works

1. Ingest coverage report (lcov, cobertura, or similar) and mutation report (stryker, mutmut, pitest). 2. For each file, compute per-line (executed, mutant_killed, mutant_survived). 3. Rank lines by (high-execute, low-kill) — those are 'covered but untested.' 4. Cluster nearby surviving mutants into 'behaviors' using AST proximity. 5. For each behavior, prompt the LLM for a plain-English description of what the test would assert, using the surrounding code as context. 6. Emit a prioritized markdown report grouped by file, ordered by mutant survival count.
