Skip to content

Usage

Terminal window
# Analyze a coverage report
code-covered coverage.json
# Show full test templates
code-covered coverage.json -v
Terminal window
# Filter by priority level
code-covered coverage.json --priority critical
code-covered coverage.json --priority high
# Limit number of suggestions
code-covered coverage.json --limit 5
Terminal window
# Write test stubs to a file
code-covered coverage.json -o tests/test_missing.py
# JSON output for CI pipelines
code-covered coverage.json --format json
# Specify source root (if coverage paths are relative)
code-covered coverage.json --source-root ./src

Every gap is classified before it surfaces:

PriorityTriggered byExample
CriticalException handlers, raise statementsexcept ValueError: never triggered
HighConditional branchesif x > 0: branch never taken
MediumFunction bodies, loopsLoop body never entered
LowOther uncovered codeModule-level statements

Each suggestion includes a ready-to-use test template following the Arrange/Act/Assert pattern:

def test_validate_input_handles_exception():
"""Test that validate_input handles ValueError."""
# Arrange: Set up conditions to trigger ValueError
# TODO: Mock dependencies to raise ValueError
# Act
result = validate_input() # TODO: Add args
# Assert: Verify exception was handled correctly
# TODO: Add assertions

code-covered detects common patterns in your code and suggests what to mock:

Hints: Mock HTTP requests with responses or httpx, Use @pytest.mark.asyncio decorator

Use code-covered programmatically:

from analyzer import find_coverage_gaps, print_coverage_gaps
# Find gaps
suggestions, warnings = find_coverage_gaps("coverage.json")
# Print formatted output
print_coverage_gaps(suggestions)
# Or process programmatically
for s in suggestions:
print(f"{s.priority}: {s.test_name}")
print(f" Covers lines {s.covers_lines}")
print(f" Template:\n{s.code_template}")

Use JSON output to integrate with CI pipelines:

{
"coverage_percent": 74.5,
"files_analyzed": 3,
"files_with_gaps": 1,
"suggestions": [
{
"test_name": "test_validator_validate_input_handles_exception",
"priority": "critical",
"covers_lines": [23, 24, 25, 26, 27],
"block_type": "exception_handler"
}
]
}