coverage-analysis
Code coverage analysis using coverage.sh script and pytest-cov
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 6
- Forks
- 0
01 前言 Front Matter
- type
- usage
- scope
- project
- description
- Code coverage analysis using coverage.sh script and pytest-cov
03 SKILL.md 正文
Coverage Analysis Guide
Purpose
Provide Claude with a comprehensive reference for running code coverage analysis in Your Project. This skill covers the coverage.sh script usage, interpreting results, and best practices.
Activation Cues
- Running coverage analysis
- Checking test coverage before PRs
- Investigating which code paths need more tests
- Generating coverage reports
Quick Reference
# Run coverage with HTML report (default)
./coverage.sh
# Run coverage with text report only (faster)
./coverage.sh --no-html
# Include integration tests
./coverage.sh --integration
# Include integration tests, text only
./coverage.sh --integration --no-html
Output Locations
| Output | Location |
|---|---|
| Text report | /tmp/$PROJECT_NAME/coverage/coverage_report.txt |
| HTML report | /tmp/$PROJECT_NAME/coverage/index.html |
| Quick link | file:///tmp/coverage.html (symlink) |
Understanding Results
Test Summary
Test Summary:
Total tests: 232
Passed: 204
Failed: 28
Coverage Summary
Overall Coverage: 69%
Key Files Coverage:
main.py 44%
llm_service.py 74%
game_state.py 57%
firestore_service.py 53%
Coverage Thresholds
CI Workflow Thresholds
| Coverage | CI Result | Badge Color |
|---|---|---|
| ≥80% | Pass | Green (MINIMUM_GREEN: 80) |
| 60-79% | Pass (warning) | Orange (MINIMUM_ORANGE: 60) |
| <60% | Fail | Red |
Quality Guidelines
| Coverage | Status | Action | CI Threshold |
|---|---|---|---|
| 80%+ | Excellent | Maintain | Green (MINIMUM_GREEN: 80) |
| 60-79% | Good | Minor improvements | Orange (MINIMUM_ORANGE: 60) |
| 40-59% | Fair | Add targeted tests | Warning |
| <40% | Poor | Prioritize testing | Error |
Key Files to Monitor
Priority coverage targets for Your Project:
- narrative_response_schema.py - LLM response parsing
- llm_service.py - AI integration
- world_logic.py - Core game mechanics
- firestore_service.py - Data persistence
- game_state.py - State management
- main.py - API endpoints
Running Single Test Files
For focused development, run individual test files:
# Using venv with proper PYTHONPATH
source venv/bin/activate
PYTHONPATH="$PWD:$PYTHONPATH" TESTING=true python $PROJECT_ROOT/tests/test_specific.py
Common Issues
ModuleNotFoundError: No module named 'mvp_site'
Cause: PYTHONPATH doesn't include project root.
Fix: The coverage.sh script sets PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH" automatically. For manual runs:
export PYTHONPATH="$PWD:$PYTHONPATH"
Test Fails with Missing Dependencies
Fix: Install test dependencies:
pip install numpy fastembed onnxruntime
Browser/Integration Tests Failing
Some tests require additional setup:
- Browser tests need Playwright:
playwright install - Integration tests may need running services
GitHub Actions Integration
For CI coverage reporting, use py-cov-action/python-coverage-comment-action@v3.32 (SHA-pinned in workflow):
- name: Coverage comment
uses: py-cov-action/python-coverage-comment-action@fb02115d6115e7b3325dc3295fe1dcfb1919248a # v3.32
with:
GITHUB_TOKEN: ${{ github.token }}
MINIMUM_GREEN: 80
MINIMUM_ORANGE: 60
See .github/workflows/coverage.yml for the full workflow with threshold checks.
Best Practices
- Run before PRs: Check coverage impact before submitting
- Focus on critical paths: Prioritize business logic coverage
- Don't chase 100%: Focus on meaningful test coverage
- Review uncovered lines: Use HTML report for line-by-line analysis
- Mock external services: Use
TESTING=truefor isolated testing
Related Skills
end2end-testing.md- E2E test patternsevidence-standards.md- Test evidence collection
04 同仓库更多 Skills
instinct
Use when the user invokes /instinct or /in, or asks to "message Instinct", "ask Instinct", "tell Instinct", "check Instinct", or read replies from the configured peer assistant. iMessage first, WhatsApp Web as fallback.
hr
Compatibility alias for history-resume; produce the same fresh-state, provenance-aware resume briefing.
history-resume
Resume briefing for the current repository branch or worktree using fresh state and admitted history sources.
grok
Alias for the canonical grokbot browser conversation workflow; /grok talks to the Grok bot the same way /dot talks to Dot.
codexa-bench
Compare `codexa` and normal `codex` on a fair split of comparable work by default; use `--strict` for duplicate runs of the exact same task.
frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.