qe-coverage-analysis について
QA チーム向けのカバレッジ分析スキルです。カバレッジのギャップ検出、リスク評価、コードの重要度に基づくテスト優先順位付けを行います。サブリニアなギャップ検出と、ブランチ間の差分分析にも対応します。
主な機能
- 01サブリニアなカバレッジギャップ検出
- 02ステートメント・分岐・関数の指標
- 03リスク加重カバレッジスコア
- 04差分カバレッジ分析
- 05カバレッジしきい値と品質ゲート
- 06カバレッジレポートと実行履歴
活用シーン
- 01未カバーの重要コードの特定
- 02コードリスクに基づくテスト優先順位付け
- 03ブランチ間のカバレッジ比較
- 04変更に対するカバレッジ要件の適用
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ proffesor-for-testing/ agentic-qe --skill qe-coverage-analysisインストール後、Claude Code で/qe-coverage-analysisを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
run-history.jsonevals/qe-coverage-analysis.yamlschemas/output.jsonscripts/validate-config.json詳細
QE カバレッジ分析
目的
サブリニアなギャップ検出アルゴリズム、リスク加重カバレッジスコアリング、コードの重要度に基づくインテリジェントなテスト優先順位付けなど、v3 の高度なカバレッジ分析機能の使用方法を説明します。
有効化
- テストカバレッジを分析するとき
- カバレッジのギャップを特定するとき
- テストにかける労力の優先順位を決めるとき
- カバレッジ目標を設定するとき
- コードのリスクを評価するとき
クイックスタート
# Analyze coverage with gap detection
aqe coverage analyze --source src/ --tests tests/
# Find high-risk uncovered code
aqe coverage gaps --risk-weighted --threshold 80
# Generate coverage report
aqe coverage report --format html --output coverage-report/
# Compare coverage between branches
aqe coverage diff --base main --head feature-branch
エージェントのワークフロー
// Comprehensive coverage analysis
Task("Analyze coverage gaps", `
Perform O(log n) coverage analysis on src/:
- Calculate statement, branch, function coverage
- Identify uncovered critical paths
- Risk-weight gaps by code complexity and change frequency
- Recommend tests to write for maximum coverage impact
`, "qe-coverage-specialist")
// Risk-based prioritization
Task("Prioritize coverage effort", `
Analyze coverage gaps and prioritize by:
- Business criticality (payment, auth, data)
- Code complexity (cyclomatic > 10)
- Recent bug history
- Change frequency
Output prioritized list of files needing tests.
`, "qe-coverage-analyzer")
分析戦略
1. サブリニアなギャップ検出
await coverageAnalyzer.detectGaps({
algorithm: 'sublinear', // O(log n) complexity
source: 'src/**/*.ts',
metrics: ['statement', 'branch', 'function'],
sampling: {
enabled: true,
confidence: 0.95,
maxSamples: 1000
}
});
2. リスク加重カバレッジ
await coverageAnalyzer.riskWeightedAnalysis({
coverage: coverageReport,
riskFactors: {
complexity: { weight: 0.3, threshold: 10 },
changeFrequency: { weight: 0.25, window: '90d' },
bugHistory: { weight: 0.25, window: '180d' },
criticality: { weight: 0.2, tags: ['payment', 'auth'] }
},
output: {
riskScore: true,
prioritizedGaps: true
}
});
3. 差分カバレッジ
await coverageAnalyzer.diffCoverage({
base: 'main',
head: 'feature-branch',
requirements: {
newCode: 80, // New code must have 80% coverage
modifiedCode: 'maintain', // Don't decrease existing
deletedCode: 'ignore'
}
});
カバレッジのしきい値
thresholds:
global:
statements: 80
branches: 75
functions: 85
lines: 80
per_file:
min_statements: 70
critical_paths: 90
new_code:
statements: 85
branches: 80
exceptions:
- path: "src/migrations/**"
reason: "Database migrations"
- path: "src/generated/**"
reason: "Auto-generated code"
カバレッジレポート
interface CoverageAnalysis {
summary: {
statements: { covered: number; total: number; percentage: number };
branches: { covered: number; total: number; percentage: number };
functions: { covered: number; total: number; percentage: number };
};
gaps: {
file: string;
uncoveredLines: number[];
uncoveredBranches: BranchInfo[];
riskScore: number;
suggestedTests: string[];
}[];
trends: {
period: string;
coverageChange: number;
newGaps: number;
closedGaps: number;
};
recommendations: {
priority: 'critical' | 'high' | 'medium' | 'low';
file: string;
action: string;
expectedImpact: number;
}[];
}
品質ゲート
quality_gates:
coverage:
block_merge:
- new_code_coverage < 80
- coverage_regression > 5
- critical_path_uncovered
warn:
- overall_coverage < 75
- branch_coverage < 70
metrics:
- track_trends: true
- alert_on_decline: 3 # consecutive PRs
実行履歴
各カバレッジ分析の後、このスキルのディレクトリにある run-history.json に結果を追記します。
# Read current history, append new entry, write back
node -e "
const fs = require('fs');
const h = JSON.parse(fs.readFileSync('.claude/skills/qe-coverage-analysis/run-history.json'));
h.runs.push({date: new Date().toISOString().split('T')[0], statements_pct: STATEMENTS, branches_pct: BRANCHES, gaps_found: GAPS});
fs.writeFileSync('.claude/skills/qe-coverage-analysis/run-history.json', JSON.stringify(h, null, 2));
"
各実行の前に run-history.json を読み込み、「カバレッジが3回連続で低下した」などの傾向を検出します。
スキルの組み合わせ
- カバレッジが低下しましたか? →
/coverage-drop-investigatorを使って原因を追跡します - テストを増やす必要がありますか? →
/qe-test-generationを使ってギャップを埋めます - 品質を検証しますか? → カバレッジが品質を意味することを確認するため、
/mutation-testingを使います - リリースを判断しますか? →
/qe-quality-assessmentに渡してデプロイ可能性を評価します
注意点
- 高い行カバレッジは、優れたテストを意味するとは限りません。アサーションが0%なのにカバレッジが100%というのは、エージェントの出力でよくあります。ミューテーションテストで検証してください
- coverage-analysis ドメインの成功率は86%で、実行の14%は初期化に失敗します。必ず結果を確認し、代替手段(手動のカバレッジツールなど)を用意してください
- 自己学習パイプラインは、学習をひそかに停止することがあります(ステータスラインが何日も更新されないなど)。これを検出できるのは、人による確認だけです
連携
主要エージェント:qe-coverage-specialist、qe-coverage-analyzer、qe-gap-detector コーディネーター:qe-coverage-coordinator 関連スキル:qe-test-generation、qe-quality-assessment
コメント
Markdown 対応