test-coverage
Analyze test coverage and generate a detailed coverage report
When & Why to Use This Skill
The Test Coverage skill empowers developers to maintain high code quality by automatically analyzing LCOV coverage data. It transforms raw test results into actionable insights, highlighting covered and uncovered functions, calculating precise coverage percentages, and providing strategic recommendations for future testing priorities to ensure robust software development.
Use Cases
- Automated Quality Audits: Quickly assess the testing state of a repository after running a test suite to ensure compliance with project quality standards.
- Identifying Testing Gaps: Pinpoint specific functions and line ranges that lack test coverage, allowing developers to focus their efforts on high-risk, untested code paths.
- Coverage Trend Analysis: Compare current coverage data with previous results to visualize improvements or regressions in the codebase's test suite over time.
- Actionable Testing Roadmaps: Generate a prioritized list of recommendations for which functions should be tested next based on their importance and current coverage impact.
| name | test-coverage |
|---|---|
| description | Analyze test coverage and generate a detailed coverage report |
Test Coverage Report Skill
This skill analyzes test coverage for the codebase and generates a detailed report.
Instructions
When this skill is invoked, you should:
Parse the coverage data if it exists:
- If it does not exist, run tests first
- If it still does not exist, do not proceed further
- Read the coverage file:
coverage/lcov-buttercup.info - Parse LCOV format to extract:
- Lines with execution counts (DA:line_number,count)
- Total lines and covered lines
- Coverage percentage
Identify covered code sections:
- Find which line ranges are covered (count > 0)
- Group consecutive covered lines into ranges
- Read the source file to identify which functions are covered
Generate a comprehensive report including:
- Test execution summary (pass/fail count, execution time)
- Overall coverage statistics (lines covered, percentage)
- List of tested functions with their line ranges
- List of untested functions
- Coverage trend if previous coverage data is available
- Recommendations for next testing priorities
Format the output with:
- Clear sections and headers
- Tables for statistics
- Easy-to-read formatting using markdown
Coverage Calculation Formula
Coverage % = (Lines with count > 0) / (Total lines) * 100
Example Output Format
## Test Coverage Report
### Test Execution
- ✅ All X tests passed
- Execution time: Y ms
### Coverage Statistics
- Lines covered: X/Y (Z%)
- Previous coverage: A/B (C%)
- Change: +D lines (+E%)
### Tested Functions
1. function-name (lines X-Y) - Z lines covered
2. another-function (lines A-B) - C lines covered
### Coverage Gaps
- untested-function (lines X-Y) - D lines
- another-untested (lines A-B) - E lines
### Recommendations
The next most valuable functions to test are:
...
Notes
- Always verify the coverage directory exists before attempting to read it
- Handle missing or malformed coverage data gracefully
- Provide actionable recommendations based on function importance and coverage impact