Usage
CLI commands
Section titled “CLI commands”Basic analysis
Section titled “Basic analysis”# Analyze a coverage reportcode-covered coverage.json
# Show full test templatescode-covered coverage.json -vFiltering and limiting
Section titled “Filtering and limiting”# Filter by priority levelcode-covered coverage.json --priority criticalcode-covered coverage.json --priority high
# Limit number of suggestionscode-covered coverage.json --limit 5Output options
Section titled “Output options”# Write test stubs to a filecode-covered coverage.json -o tests/test_missing.py
# JSON output for CI pipelinescode-covered coverage.json --format json
# Specify source root (if coverage paths are relative)code-covered coverage.json --source-root ./srcPriority levels
Section titled “Priority levels”Every gap is classified before it surfaces:
| Priority | Triggered by | Example |
|---|---|---|
| Critical | Exception handlers, raise statements | except ValueError: never triggered |
| High | Conditional branches | if x > 0: branch never taken |
| Medium | Function bodies, loops | Loop body never entered |
| Low | Other uncovered code | Module-level statements |
Test templates
Section titled “Test templates”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 assertionsSetup hints
Section titled “Setup hints”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 decoratorPython API
Section titled “Python API”Use code-covered programmatically:
from analyzer import find_coverage_gaps, print_coverage_gaps
# Find gapssuggestions, warnings = find_coverage_gaps("coverage.json")
# Print formatted outputprint_coverage_gaps(suggestions)
# Or process programmaticallyfor s in suggestions: print(f"{s.priority}: {s.test_name}") print(f" Covers lines {s.covers_lines}") print(f" Template:\n{s.code_template}")CI integration
Section titled “CI integration”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" } ]}