Test Coverage
Measure, analyze, and report test coverage across all test types, including code coverage, requirement coverage, risk coverage, and quality attribute coverage.
When to use me
Use this skill when:
- Assessing overall test effectiveness
- Identifying coverage gaps in testing strategy
- Reporting test coverage to stakeholders
- Planning test improvement initiatives
- Validating test completeness for releases
- Comparing actual vs planned test coverage
- Tracking coverage trends over time
What I do
Multi-dimensional coverage analysis:
- Code coverage: statements, branches, functions, lines
- Requirement coverage: functional and non-functional requirements
- Risk coverage: high-risk areas and scenarios
- Quality attribute coverage: performance, security, usability, etc.
- User scenario coverage: user journeys and workflows
Coverage measurement:
- Automated coverage collection from test execution
- Manual coverage assessment for exploratory testing
- Integration with test management tools
- Historical coverage trend analysis
Gap analysis and recommendations:
- Identify under-tested areas and components
- Recommend test type mix adjustments
- Suggest coverage improvement strategies
- Prioritize coverage gaps based on risk
Reporting and visualization:
- Generate coverage reports for different stakeholders
- Create coverage dashboards and visualizations
- Track coverage against targets and benchmarks
- Provide coverage insights for decision making
Coverage Dimensions
- Code Coverage: What code is executed by tests?
- Requirement Coverage: What requirements are validated by tests?
- Risk Coverage: What risks are mitigated by tests?
- Scenario Coverage: What user scenarios are tested?
- Data Coverage: What data variations are tested?
- Configuration Coverage: What configurations are tested?
Examples
# Measure overall test coverage
npm run test:coverage:measure # Comprehensive coverage measurement
npm run test:coverage:report # Generate coverage report
# Specific coverage types
npm run test:coverage:code # Code coverage analysis
npm run test:coverage:requirements # Requirement coverage analysis
npm run test:coverage:risks # Risk coverage analysis
npm run test:coverage:scenarios # Scenario coverage analysis
npm run test:coverage:data # Data coverage analysis
# Integration with test types
npm run test:coverage -- --include unit,integration,e2e
npm run test:coverage -- --exclude performance,security
npm run test:coverage -- --type functional
npm run test:coverage -- --type nonfunctional
# Coverage visualization
npm run test:coverage:visualize # Generate coverage visualizations
npm run test:coverage:dashboard # Coverage dashboard
npm run test:coverage:trends # Coverage trend analysis
# Coverage targets
npm run test:coverage:targets # Check against coverage targets
npm run test:coverage:gaps # Identify coverage gaps
Output format
Test Coverage Analysis Report
──────────────────────────────
Project: Customer Portal v1.3
Analysis Period: Last 30 days
Test Types Included: 8 of 12
Overall Coverage Summary:
- Code Coverage: 78% (target: 80%)
- Requirement Coverage: 92% (target: 95%)
- Risk Coverage: 85% (target: 90%)
- Scenario Coverage: 88% (target: 85% ✓)
- Quality Attribute Coverage: 72% (target: 75%)
Code Coverage Detail:
- Statements: 82% (45,210/55,134)
- Branches: 71% (12,345/17,390)
- Functions: 85% (3,456/4,067)
- Lines: 80% (38,765/48,456)
By Test Type Contribution:
Unit Tests:
- Code Coverage: 65% primary contributor
- Fastest feedback, highest volume
Integration Tests:
- Code Coverage: +12% incremental
- API and database coverage
E2E Tests:
- Code Coverage: +1% incremental
- User journey coverage
Security Tests:
- Requirement Coverage: +15% security requirements
- No code coverage contribution
Requirement Coverage:
Functional Requirements: 145/150 (97%)
- Missing: FR-23 (reporting export), FR-45 (bulk update)
Non-Functional Requirements: 28/35 (80%)
- Missing: NFR-12 (concurrent users), NFR-18 (data retention)
Risk Coverage:
High Risks: 8/10 covered (80%)
- Uncovered: R-05 (payment failure), R-09 (data corruption)
Medium Risks: 22/25 covered (88%)
Low Risks: 45/50 covered (90%)
Scenario Coverage:
User Journeys: 15/18 covered (83%)
- Uncovered: Guest checkout, Account deletion
Business Processes: 8/10 covered (80%)
Admin Flows: 6/8 covered (75%)
Coverage by Component:
- Authentication: 95% (excellent)
- User Management: 88% (good)
- Billing: 65% (needs improvement)
- Reporting: 45% (poor)
- API Gateway: 92% (good)
Coverage Gaps Analysis:
Critical Gaps:
1. Billing module has low test automation
2. Reporting features largely untested
3. Payment failure scenarios not covered
Moderate Gaps:
1. Admin flows need more test coverage
2. Edge cases in user management
Minor Gaps:
1. Some utility functions untested
2. Legacy code with no recent test updates
Test Type Effectiveness:
- Most Effective: Unit tests (high coverage, fast)
- Best for Risk Coverage: Integration tests
- Best for User Confidence: E2E tests
- Most Impactful for Quality: Security & performance tests
Recommendations:
1. Increase unit test coverage in billing module to 80%
2. Add integration tests for reporting functionality
3. Implement security tests for payment processing
4. Create E2E tests for guest checkout scenario
5. Review and update test targets for next quarter
Trend Analysis:
- Code coverage increased from 72% to 78% this quarter
- Requirement coverage stable at 92%
- Risk coverage improved from 80% to 85%
- Positive trend overall, but billing module declining
Notes
- Coverage metrics should inform, not drive, testing decisions
- Different coverage types matter for different contexts
- High coverage doesn't guarantee high quality, but low coverage often indicates risk
- Balance coverage metrics with other quality indicators
- Use coverage data to guide test improvement, not as a punitive measure
- Consider coverage context (legacy code vs new development)
- Automate coverage collection where possible
- Review coverage regularly, not just before releases
- Share coverage insights with development teams
- Use coverage as one input among many for quality assessment
1---2name: test-coverage3description: Measure and report test coverage across all test types4license: MIT5compatibility: opencode6metadata:7 audience: developers8 category: testing9---1011# Test Coverage1213Measure, analyze, and report test coverage across all test types, including code coverage, requirement coverage, risk coverage, and quality attribute coverage.1415## When to use me1617Use this skill when:18- Assessing overall test effectiveness19- Identifying coverage gaps in testing strategy20- Reporting test coverage to stakeholders21- Planning test improvement initiatives22- Validating test completeness for releases23- Comparing actual vs planned test coverage24- Tracking coverage trends over time2526## What I do2728- **Multi-dimensional coverage analysis**:29 - Code coverage: statements, branches, functions, lines30 - Requirement coverage: functional and non-functional requirements31 - Risk coverage: high-risk areas and scenarios32 - Quality attribute coverage: performance, security, usability, etc.33 - User scenario coverage: user journeys and workflows3435- **Coverage measurement**:36 - Automated coverage collection from test execution37 - Manual coverage assessment for exploratory testing38 - Integration with test management tools39 - Historical coverage trend analysis4041- **Gap analysis and recommendations**:42 - Identify under-tested areas and components43 - Recommend test type mix adjustments44 - Suggest coverage improvement strategies45 - Prioritize coverage gaps based on risk4647- **Reporting and visualization**:48 - Generate coverage reports for different stakeholders49 - Create coverage dashboards and visualizations50 - Track coverage against targets and benchmarks51 - Provide coverage insights for decision making5253## Coverage Dimensions54551. **Code Coverage**: What code is executed by tests?562. **Requirement Coverage**: What requirements are validated by tests?573. **Risk Coverage**: What risks are mitigated by tests?584. **Scenario Coverage**: What user scenarios are tested?595. **Data Coverage**: What data variations are tested?606. **Configuration Coverage**: What configurations are tested?6162## Examples6364```bash65# Measure overall test coverage66npm run test:coverage:measure # Comprehensive coverage measurement67npm run test:coverage:report # Generate coverage report6869# Specific coverage types70npm run test:coverage:code # Code coverage analysis71npm run test:coverage:requirements # Requirement coverage analysis72npm run test:coverage:risks # Risk coverage analysis73npm run test:coverage:scenarios # Scenario coverage analysis74npm run test:coverage:data # Data coverage analysis7576# Integration with test types77npm run test:coverage -- --include unit,integration,e2e78npm run test:coverage -- --exclude performance,security79npm run test:coverage -- --type functional80npm run test:coverage -- --type nonfunctional8182# Coverage visualization83npm run test:coverage:visualize # Generate coverage visualizations84npm run test:coverage:dashboard # Coverage dashboard85npm run test:coverage:trends # Coverage trend analysis8687# Coverage targets88npm run test:coverage:targets # Check against coverage targets89npm run test:coverage:gaps # Identify coverage gaps90```9192## Output format9394```95Test Coverage Analysis Report96──────────────────────────────97Project: Customer Portal v1.398Analysis Period: Last 30 days99Test Types Included: 8 of 12100101Overall Coverage Summary:102 - Code Coverage: 78% (target: 80%)103 - Requirement Coverage: 92% (target: 95%)104 - Risk Coverage: 85% (target: 90%)105 - Scenario Coverage: 88% (target: 85% ✓)106 - Quality Attribute Coverage: 72% (target: 75%)107108Code Coverage Detail:109 - Statements: 82% (45,210/55,134)110 - Branches: 71% (12,345/17,390)111 - Functions: 85% (3,456/4,067)112 - Lines: 80% (38,765/48,456)113114By Test Type Contribution:115 Unit Tests:116 - Code Coverage: 65% primary contributor117 - Fastest feedback, highest volume118 119 Integration Tests:120 - Code Coverage: +12% incremental121 - API and database coverage122 123 E2E Tests:124 - Code Coverage: +1% incremental 125 - User journey coverage126 127 Security Tests:128 - Requirement Coverage: +15% security requirements129 - No code coverage contribution130131Requirement Coverage:132 Functional Requirements: 145/150 (97%)133 - Missing: FR-23 (reporting export), FR-45 (bulk update)134 135 Non-Functional Requirements: 28/35 (80%)136 - Missing: NFR-12 (concurrent users), NFR-18 (data retention)137138Risk Coverage:139 High Risks: 8/10 covered (80%)140 - Uncovered: R-05 (payment failure), R-09 (data corruption)141 142 Medium Risks: 22/25 covered (88%)143 Low Risks: 45/50 covered (90%)144145Scenario Coverage:146 User Journeys: 15/18 covered (83%)147 - Uncovered: Guest checkout, Account deletion148 149 Business Processes: 8/10 covered (80%)150 Admin Flows: 6/8 covered (75%)151152Coverage by Component:153 - Authentication: 95% (excellent)154 - User Management: 88% (good)155 - Billing: 65% (needs improvement)156 - Reporting: 45% (poor)157 - API Gateway: 92% (good)158159Coverage Gaps Analysis:160 Critical Gaps:161 1. Billing module has low test automation162 2. Reporting features largely untested163 3. Payment failure scenarios not covered164 165 Moderate Gaps:166 1. Admin flows need more test coverage167 2. Edge cases in user management168 169 Minor Gaps:170 1. Some utility functions untested171 2. Legacy code with no recent test updates172173Test Type Effectiveness:174 - Most Effective: Unit tests (high coverage, fast)175 - Best for Risk Coverage: Integration tests176 - Best for User Confidence: E2E tests177 - Most Impactful for Quality: Security & performance tests178179Recommendations:180 1. Increase unit test coverage in billing module to 80%181 2. Add integration tests for reporting functionality182 3. Implement security tests for payment processing183 4. Create E2E tests for guest checkout scenario184 5. Review and update test targets for next quarter185186Trend Analysis:187 - Code coverage increased from 72% to 78% this quarter188 - Requirement coverage stable at 92%189 - Risk coverage improved from 80% to 85%190 - Positive trend overall, but billing module declining191```192193## Notes194195- Coverage metrics should inform, not drive, testing decisions196- Different coverage types matter for different contexts197- High coverage doesn't guarantee high quality, but low coverage often indicates risk198- Balance coverage metrics with other quality indicators199- Use coverage data to guide test improvement, not as a punitive measure200- Consider coverage context (legacy code vs new development)201- Automate coverage collection where possible202- Review coverage regularly, not just before releases203- Share coverage insights with development teams204- Use coverage as one input among many for quality assessment