Note: smart-test internals

How the feature is structured

Smart-test is implemented across two workflow packages:

How the two sides compose

The audit and generation packages are designed to pipeline. parse_coverage_json() reads pytest-cov's coverage.json and returns a list of ModuleCoverage dataclasses. prioritize_modules() filters that list to modules below a coverage threshold (default: 50%) and sorts by gap size. group_into_batches() then groups the result by package path into up to five subsystem batches, which TestGenerationWorkflow or ParallelTestGenerationWorkflow consumes to drive test writing.

ASTFunctionAnalyzer sits at the boundary: it takes raw source and returns FunctionSignature and ClassSignature records that carry parameter types, return types, raised exceptions, async status, and cyclomatic complexity. generate_test_for_function() and generate_test_for_class() consume those records to produce executable pytest output.

Audit orchestration

TestAuditWorkflow uses the system prompt in AUDIT_SYSTEM_PROMPT to instruct a coverage-analyst agent to review module prioritization, then PLAN_SYSTEM_PROMPT to group modules into logical batches. Each batch is rendered with BATCH_TASK_TEMPLATE, which embeds source path, missing line summary, coverage target, and test class stubs in a structured XML prompt.

The final report from _TASK_PROMPT_TEMPLATE has four sections: Summary (health score 0–100), Coverage, Test Gaps, and Suggestions (prioritized, with effort estimates).

Source files

Tags: tests, coverage, generation