Validate WCAG 2.1 Level AA compliance and accessibility best practices. Use when performing accessibility audits and WCAG certification.
日本語の概要は準備中です。原文の説明を表示しています。
Analyze test coverage with detailed metrics, identify gaps, and generate comprehensive reports. Use when measuring code coverage, finding untested code, or validating coverage thresholds.
インストール方法を見るインストールする前に、エージェントに与えられる指示の中身を確認できます。
This skill provides comprehensive test coverage analysis, gap identification, threshold validation, and detailed reporting to ensure code quality and adequate test coverage across the codebase.
Run Tests with Coverage:
# Install pytest-cov if not installed
pip install pytest-cov
# Basic coverage measurement
pytest --cov=src tests/
# Coverage with terminal report
pytest --cov=src --cov-report=term tests/
# Coverage with missing lines
pytest --cov=src --cov-report=term-missing tests/
# Coverage for specific module
pytest --cov=src.tools.feature tests/
Quick Coverage Check:
# Show percentage only
pytest --cov=src --cov-report=term tests/ | grep TOTAL
# Check if coverage meets threshold
pytest --cov=src --cov-fail-under=80 tests/
# Quiet mode with coverage
pytest --cov=src --cov-report=term -q tests/
Deliverable: Basic coverage metrics
Generate Detailed Reports:
# HTML coverage report (most detailed)
pytest --cov=src --cov-report=html tests/
# Open htmlcov/index.html in browser
# XML coverage report (for CI/CD)
pytest --cov=src --cov-report=xml tests/
# JSON coverage report
pytest --cov=src --cov-report=json tests/
# Multiple report formats
pytest --cov=src \
--cov-report=html \
--cov-report=xml \
--cov-report=term-missing \
tests/
Analyze Coverage by Module:
# Show coverage for each file
pytest --cov=src --cov-report=term tests/
# Coverage with line numbers
pytest --cov=src --cov-report=term-missing tests/
# Annotated source files
pytest --cov=src --cov-report=annotate tests/
# Creates .py,cover files with coverage annotations
Deliverable: Detailed coverage reports
Find Untested Code:
# Show missing lines
pytest --cov=src --cov-report=term-missing tests/
# Show missing branches
pytest --cov=src --cov-branch --cov-report=term-missing tests/
# Generate HTML report to visualize gaps
pytest --cov=src --cov-report=html tests/
# Open htmlcov/index.html to see line-by-line coverage
Identify Low Coverage Modules:
# Run coverage and parse output
pytest --cov=src --cov-report=term tests/ | grep -v "100%"
# Find files below 80% coverage
pytest --cov=src --cov-report=term tests/ | awk '$NF ~ /%/ && $NF+0 < 80'
# Sort by coverage percentage
pytest --cov=src --cov-report=term tests/ | sort -k4 -n
Analyze Coverage by Test Type:
# Coverage from unit tests only
pytest --cov=src --cov-report=term tests/unit/
# Coverage from integration tests only
pytest --cov=src --cov-report=term tests/integration/
# Combined coverage
pytest --cov=src --cov-report=term tests/unit/ tests/integration/
# Incremental coverage (append mode)
pytest --cov=src --cov-append --cov-report=term tests/unit/
pytest --cov=src --cov-append --cov-report=term tests/integration/
Deliverable: Coverage gap analysis
Measure Branch Coverage:
# Enable branch coverage
pytest --cov=src --cov-branch --cov-report=term-missing tests/
# Branch coverage with HTML report
pytest --cov=src --cov-branch --cov-report=html tests/
# Show partial branches
pytest --cov=src --cov-branch --cov-report=term-missing tests/ | grep "!->"
Analyze Conditional Coverage:
# Find untested conditionals
pytest --cov=src --cov-branch --cov-report=term-missing tests/ | grep "if"
# Check switch/case coverage
pytest --cov=src --cov-branch --cov-report=term-missing tests/ | grep "case"
Deliverable: Branch coverage metrics
Validate Minimum Coverage:
# Fail if coverage below 80%
pytest --cov=src --cov-fail-under=80 tests/
# Fail if coverage below 90%
pytest --cov=src --cov-fail-under=90 tests/
# Check with specific threshold and report
pytest --cov=src --cov-fail-under=80 --cov-report=term-missing tests/
Per-Module Thresholds:
# Core logic: 90% minimum
pytest --cov=src.core --cov-fail-under=90 tests/
# Utilities: 85% minimum
pytest --cov=src.utils --cov-fail-under=85 tests/
# Interfaces: 80% minimum
pytest --cov=src.interfaces --cov-fail-under=80 tests/
Deliverable: Threshold validation report
Configure .coveragerc:
# .coveragerc
[run]
source = src
omit =
tests/*
*/__init__.py
*/venv/*
*/.venv/*
*/migrations/*
branch = True
[report]
exclude_lines =
# Default pragmas
pragma: no cover
# Don't complain about missing debug-only code
def __repr__
def __str__
# Don't complain if tests don't hit defensive assertion code
raise AssertionError
raise NotImplementedError
# Don't complain if non-runnable code isn't run
if __name__ == .__main__.:
if TYPE_CHECKING:
# Don't complain about abstract methods
@abstractmethod
precision = 2
show_missing = True
[html]
directory = htmlcov
[xml]
output = coverage.xml
Configure pyproject.toml:
# pyproject.toml
[tool.coverage.run]
source = ["src"]
omit = [
"tests/*",
"*/__init__.py",
"*/venv/*",
"*/.venv/*",
]
branch = true
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"@abstractmethod",
]
precision = 2
show_missing = true
fail_under = 80
[tool.coverage.html]
directory = "htmlcov"
[tool.coverage.xml]
output = "coverage.xml"
Deliverable: Coverage configuration
Generate Coverage Reports:
# Terminal report
pytest --cov=src --cov-report=term tests/
# Terminal report with missing lines
pytest --cov=src --cov-report=term-missing tests/
# HTML report for detailed analysis
pytest --cov=src --cov-report=html tests/
# XML report for CI/CD integration
pytest --cov=src --cov-report=xml tests/
# JSON report for programmatic access
pytest --cov=src --cov-report=json tests/
# All reports
pytest --cov=src \
--cov-report=term-missing \
--cov-report=html \
--cov-report=xml \
--cov-report=json \
tests/
Coverage Summary Report:
# Coverage Report
## Overall Coverage: 87%
### By Module
| Module | Coverage | Missing Lines |
|--------|----------|---------------|
| src.core | 95% | 45-47, 89 |
| src.utils | 88% | 12-15, 67-70 |
| src.interfaces | 82% | 23, 56-58 |
| src.models | 100% | - |
### Critical Gaps
1. Error handling in `src.core.process()` (lines 45-47)
2. Edge case validation in `src.utils.validate()` (lines 67-70)
3. Exception paths in `src.interfaces.execute()` (lines 56-58)
### Recommendations
- Add tests for error conditions in core module
- Improve edge case coverage in utilities
- Test exception handling in interfaces
### Status
✅ Overall coverage: 87% (target: 80%)
✅ Core business logic: 95% (target: 90%)
✅ Utilities: 88% (target: 85%)
✅ All thresholds met
Deliverable: Comprehensive coverage reports
Track Coverage Over Time:
# Generate coverage badge
pip install coverage-badge
coverage-badge -o coverage.svg
# Save coverage history
pytest --cov=src --cov-report=json tests/
mv coverage.json coverage-$(date +%Y%m%d).json
# Compare coverage between runs
coverage json
python -c "import json; print(json.load(open('coverage.json'))['totals']['percent_covered'])"
Coverage Diff:
# Coverage for current branch
pytest --cov=src --cov-report=json tests/
cp coverage.json coverage-current.json
# Coverage for main branch
git checkout main
pytest --cov=src --cov-report=json tests/
cp coverage.json coverage-main.json
# Compare
diff <(jq '.totals.percent_covered' coverage-main.json) \
<(jq '.totals.percent_covered' coverage-current.json)
Deliverable: Coverage trends and comparisons
# Fast coverage check during development
pytest --cov=src --cov-report=term-missing -q tests/unit/
# Full coverage analysis with all reports
pytest --cov=src \
--cov-branch \
--cov-report=html \
--cov-report=xml \
--cov-report=term-missing \
--cov-fail-under=80 \
tests/
# Coverage check for CI/CD pipeline
pytest --cov=src \
--cov-report=xml \
--cov-report=term \
--cov-fail-under=80 \
tests/
# Find and analyze coverage gaps
pytest --cov=src --cov-report=html tests/
# Open htmlcov/index.html
# Click on files with low coverage
# Review highlighted untested lines
By Module Type:
By Coverage Type:
Overall Project:
# Acceptable to exclude from coverage
def __repr__(self): # pragma: no cover
return f"Object({self.id})"
if __name__ == "__main__": # pragma: no cover
main()
if TYPE_CHECKING: # pragma: no cover
from typing import Optional
@abstractmethod
def interface_method(self): # pragma: no cover
pass
def debug_helper(): # pragma: no cover
# Debug code not run in production
pass
# Basic coverage
pytest --cov=src tests/
# Coverage with gaps
pytest --cov=src --cov-report=term-missing tests/
# Coverage with threshold
pytest --cov=src --cov-fail-under=80 tests/
# Branch coverage
pytest --cov=src --cov-branch --cov-report=term-missing tests/
# HTML report
pytest --cov=src --cov-report=html tests/
# Full analysis
pytest --cov=src \
--cov-branch \
--cov-report=html \
--cov-report=term-missing \
--cov-fail-under=80 \
tests/
# Install pytest-cov
pip install pytest-cov
# Verify installation
pytest --version
pip show pytest-cov
# Check source configuration
cat .coveragerc
cat pyproject.toml
# Verify source parameter
pytest --cov=src tests/ # Correct
pytest --cov tests/ # Wrong - testing test code
# Clear coverage cache
rm -rf .coverage htmlcov/
pytest --cov=src tests/
# Check omit configuration
grep -A5 "\[run\]" .coveragerc
# Verify files are imported
pytest --cov=src --cov-report=term tests/ | grep "filename"
# Check test imports
grep -r "^import\|^from" tests/
# Enable branch coverage
pytest --cov=src --cov-branch tests/
# Check configuration
grep "branch" .coveragerc
# Verify branches exist
grep -r "if\|else\|elif" src/
Input: Completed test execution with coverage enabled Process: Analyze coverage, identify gaps, validate thresholds Output: Coverage report with gap analysis and recommendations Next Step: Report to test-runner-specialist for decision
まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Validate WCAG 2.1 Level AA compliance and accessibility best practices. Use when performing accessibility audits and WCAG certification.
日本語の概要は準備中です。原文の説明を表示しています。
Analyze feature requirements, dependencies, and security considerations. Use when starting feature implementation from GitHub issues to understand scope, technical feasibility, and risks.
日本語の概要は準備中です。原文の説明を表示しています。
Run SQL queries against psql, BigQuery, or MySQL from the terminal, including natural-language-to-SQL and schema exploration. Use when analyzing data, inspecting DB state, or debugging tables. Trigger on "query the database", "SQL", "show me data from", "explore table".
日本語の概要は準備中です。原文の説明を表示しています。
Design REST APIs or function contracts with clear request/response specifications, error handling patterns, authentication strategies, and comprehensive documentation.
日本語の概要は準備中です。原文の説明を表示しています。
Generate comprehensive API endpoint tests for REST and GraphQL APIs. Creates tests for all HTTP methods, status codes, authentication, and validation.
日本語の概要は準備中です。原文の説明を表示しています。
Design component architecture and module structure using established architectural patterns for clean, maintainable, and scalable systems.
日本語の概要は準備中です。原文の説明を表示しています。