test-gap-analysis について
test-gap-analysisは、要件と既存テストを照合し、カバレッジ、テスト種別、有効性、保守、リスクに関する不足を特定するスキルです。影響度とリスクに基づいて課題を優先順位付けし、具体的な改善策の検討に役立ちます。
主な機能
- 01要件のテスト可能性を評価
- 02テストと要件・カバレッジを対応付け
- 03不足・部分的・古いテストを特定
- 04有効性とテスト種別の不足を分類
- 05影響度とリスクで優先順位付け
- 06テストケースと改善策を提案
活用シーン
- 01リリース前のテストカバレッジ確認
- 02新機能に不足するテストの特定
- 03未テストの高リスク要件を優先
- 04テスト自動化の改善計画
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ wojons/ skills --skill test-gap-analysisインストール後、Claude Code で/test-gap-analysisを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
README.mdreferences/README.mdscripts/analyze-coverage-gaps.shanalyze-risk-gaps.shgenerate-test-recommendations.shtest-mapping.sh詳細
テストギャップ分析
テストの完全性、有効性、リスクカバレッジを体系的に分析し、テストすべき要件や機能と実際のテストカバレッジとの食い違いを特定することで、ソフトウェアの品質と信頼性を向上させます。
使用する場面
次のような場合に、このスキルを使用してください。
- システムのどの部分が十分にテストされているか不明な場合
- 新機能が追加されたものの、対応するテストカバレッジがない場合
- テストリソースが限られており、最適に配分する必要がある場合
- テストカバレッジに確信を持ってリリースやデプロイに備える場合
- コンプライアンスや品質基準に照らして、テストの有効性を監査する場合
- テストが不十分な高リスク領域を特定する場合
- テスト自動化やテスト改善の取り組みを計画する場合
- 新しいチームメンバーがテストカバレッジを把握できるようにする場合
- テストインフラストラクチャの技術的負債を評価する場合
- 重要な機能が適切なテストで保護されていることを検証する場合
できること
1. 要件のテスト容易性分析
- 要件のテスト容易性を分析:各要件のテスト可能な側面を特定します
- 要件ドキュメントからテスト条件とシナリオを抽出します
- テストの種類に基づいて要件を分類します:単体テスト、統合テスト、システムテスト、受け入れテスト、パフォーマンステスト、セキュリティテスト
- テストにおける要件の明確さを評価します:曖昧な要件とテスト可能な要件を区別します
- 文書化されていないものの、テストすべき暗黙の要件を特定します
2. テストカバレッジ分析
- 既存のテストスイートを分析します:単体テスト、統合テスト、エンドツーエンドテスト、手動テスト
- テストを要件に対応付け、どの要件がテストでカバーされているかを判断します
- カバレッジ指標を測定します:行カバレッジ、分岐カバレッジ、要件カバレッジ、リスクカバレッジ
- テストギャップを特定します:テストがない要件、部分的なカバレッジ、古くなったテスト
- テストの有効性を評価します:テスト品質、不安定さ、メンテナンス負荷
3. ギャップの特定と分類
- テストカバレッジの欠落:対応するテストがない要件
- 不完全なテストカバレッジ:テストカバレッジが部分的な要件
- 古くなったテスト:現在の要件と一致しないテスト
- 有効性の低いテスト:要件を十分に検証できないテスト
- リスクカバレッジのギャップ:テストが不十分な高リスク領域
- テスト種類のギャップ:不足しているテストの種類(セキュリティ、パフォーマンス、アクセシビリティ)
4. リスクに基づく優先順位付け
- テストされていない要件のビジネス上の影響を評価します
- 不十分なテストによる技術的リスクを評価します
- 影響度と発生可能性に基づいてテストギャップの深刻度を算出します
- 修正計画に向けてテストギャップに優先順位を付けます
- 各テストギャップへの対応に必要な工数を見積もります
- リスクプロファイルに基づいてテスト戦略を提案します
5. テスト改善の提案
- ギャップに対応する具体的なテストケースを作成します
- 各ギャップに適したテストの種類とアプローチを提案します
- テスト自動化の機会を提案します
- テストインフラストラクチャの改善を提案します
- カバーされていないシナリオ向けのテストデータ戦略を設計します
- 将来のギャップを防ぐためのテストメンテナンス計画を作成します
テストギャップの種類
1. カバレッジギャップ
テストカバレッジの欠落:テストがまったくない要件
部分的なテストカバレッジ:テストカバレッジが不完全な要件
例:認証要件について、成功ケースはテストされているものの、失敗ケースはテストされていない
2. テスト種類のギャップ
テスト種類の欠落:重要なテストの種類(セキュリティ、パフォーマンスなど)が含まれていない
不適切なテストの種類:要件に対して誤ったテストの種類が選ばれている(単体テストと統合テストなど)
例:パフォーマンスが重要な機能に単体テストしかなく、パフォーマンステストがない
3. 有効性のギャップ
有効性の低いテスト:要件を十分に検証できないテスト
不安定なテスト:信頼性がなく、誤った安心感を与えるテスト
例:テストは成功するものの、実際には要件を検証していない
4. メンテナンスのギャップ
古くなったテスト:現在の要件に合っていないテスト
メンテナンスされていないテスト:頻繁に失敗するものの、修正されていないテスト
例:非推奨の機能を対象とするテストが、依然としてテストスイートに含まれている
5. リスクカバレッジのギャップ
高リスクの未テスト項目:十分にテストされていない重要な機能
低リスクの過剰テスト項目:過剰にテストされている重要度の低い機能
例:決済処理のテストが最小限である一方、UIのテストが広範囲にわたっている
分析手法
要件からのテスト抽出
def extract_testable_requirements(requirements_doc):
"""
Extract testable conditions from requirements.
"""
testable_items = []
for req in requirements_doc:
test_conditions = analyze_requirement_for_tests(req)
if test_conditions:
testable_items.append({
'requirement_id': req['id'],
'description': req['description'],
'test_conditions': test_conditions,
'test_types': determine_appropriate_test_types(req),
'priority': calculate_test_priority(req),
'risk_level': assess_requirement_risk(req)
})
return testable_items
def analyze_requirement_for_tests(requirement):
"""Extract testable conditions from a requirement."""
test_conditions = []
# Look for explicit testable statements
if 'shall' in requirement['text'].lower():
# Extract what the system shall do
import re
shall_pattern = r'shall\s+([^.!?]+)'
matches = re.findall(shall_pattern, requirement['text'], re.IGNORECASE)
test_conditions.extend(matches)
# Look for acceptance criteria
if 'acceptance_criteria' in requirement:
for criterion in requirement['acceptance_criteria']:
test_conditions.append(criterion)
# Look for constraints
if 'constraints' in requirement:
for constraint in requirement['constraints']:
test_conditions.append(f"Constraint: {constraint}")
return test_conditions
テストカバレッジのマッピング
class TestCoverageAnalyzer:
def __init__(self, requirements, tests):
self.requirements = requirements
self.tests = tests
def analyze_coverage(self):
"""Analyze test coverage of requirements."""
coverage_report = {
'requirements_count': len(self.requirements),
'tests_count': len(self.tests),
'covered_requirements': [],
'uncovered_requirements': [],
'partial_coverage': [],
'coverage_percentage': 0
}
for req in self.requirements:
matching_tests = self.find_tests_for_requirement(req)
if not matching_tests:
coverage_report['uncovered_requirements'].append({
'requirement': req,
'gap_type': 'missing_coverage'
})
elif len(matching_tests) < self.get_expected_test_count(req):
coverage_report['partial_coverage'].append({
'requirement': req,
'matching_tests': matching_tests,
'expected_count': self.get_expected_test_count(req),
'actual_count': len(matching_tests),
'gap_type': 'partial_coverage'
})
else:
coverage_report['covered_requirements'].append({
'requirement': req,
'matching_tests': matching_tests
})
coverage_report['coverage_percentage'] = (
len(coverage_report['covered_requirements']) /
len(self.requirements) * 100 if self.requirements else 0
)
return coverage_report
def find_tests_for_requirement(self, requirement):
"""Find tests that cover a requirement."""
matching_tests = []
for test in self.tests:
if self.test_covers_requirement(test, requirement):
matching_tests.append(test)
return matching_tests
def test_covers_requirement(self, test, requirement):
"""Determine if a test covers a requirement."""
# Check test name for requirement reference
if requirement['id'] in test.get('name', ''):
return True
# Check test description for requirement reference
if requirement['id'] in test.get('description', ''):
return True
# Check test tags for requirement reference
if 'tags' in test and requirement['id'] in test['tags']:
return True
# Semantic analysis (simplified)
if self.semantic_match(test.get('purpose', ''), requirement['description']):
return True
return False
リスクベースのギャップ優先順位付け
def prioritize_test_gaps(test_gaps, risk_assessment):
"""
Prioritize test gaps based on risk and impact.
"""
prioritized_gaps = []
for gap in test_gaps:
# Calculate priority score
priority_score = calculate_priority_score(gap, risk_assessment)
prioritized_gaps.append({
**gap,
'priority_score': priority_score,
'priority_level': determine_priority_level(priority_score),
'remediation_effort': estimate_remediation_effort(gap),
'risk_exposure': calculate_risk_exposure(gap, risk_assessment)
})
# Sort by priority score (descending)
prioritized_gaps.sort(key=lambda x: x['priority_score'], reverse=True)
return prioritized_gaps
def calculate_priority_score(gap, risk_assessment):
"""Calculate priority score for a test gap."""
weights = {
'business_impact': 0.4,
'technical_risk': 0.3,
'user_impact': 0.2,
'regulatory_requirement': 0.1
}
scores = {}
# Business impact score
if gap['requirement']['business_criticality'] == 'high':
scores['business_impact'] = 1.0
elif gap['requirement']['business_criticality'] == 'medium':
scores['business_impact'] = 0.5
else:
scores['business_impact'] = 0.2
# Technical risk score
if gap['requirement']['technical_complexity'] == 'high':
scores['technical_risk'] = 1.0
elif gap['requirement']['technical_complexity'] == 'medium':
scores['technical_risk'] = 0.5
else:
scores['technical_risk'] = 0.2
# User impact score
if gap['requirement']['user_exposure'] == 'high':
scores['user_impact'] = 1.0
elif gap['requirement']['user_exposure'] == 'medium':
scores['user_impact'] = 0.5
else:
scores['user_impact'] = 0.2
# Regulatory requirement score
if gap['requirement'].get('regulatory_requirement', False):
scores['regulatory_requirement'] = 1.0
else:
scores['regulatory_requirement'] = 0.0
# Calculate weighted score
weighted_score = sum(
scores[factor] * weights[factor]
for factor in weights
)
return weighted_score
例
# Analyze test coverage gaps
npm run test-gap-analysis:analyze -- --requirements specs/ --tests tests/ --output gaps.json
# Map tests to requirements
npm run test-gap-analysis:map -- --requirements requirements.md --test-suite tests/unit/ --output coverage-map.yaml
# Identify high-risk untested requirements
npm run test-gap-analysis:risk -- --requirements specs/ --tests tests/ --risk-factors risk-assessment.yaml --output risk-gaps.md
# Generate test recommendations
npm run test-gap-analysis:recommend -- --gaps gaps.json --output recommendations.md
# Calculate test coverage metrics
npm run test-gap-analysis:metrics -- --requirements specs/ --tests tests/ --output metrics.json
# Continuous test gap monitoring
npm run test-gap-analysis:monitor -- --watch --requirements specs/ --tests tests/ --alert-on-gap
出力形式
テストギャップ分析レポート:
Test Gap Analysis Report
────────────────────────
System: Payment Processing Service
Analysis Date: 2026-02-26
Requirements Analyzed: 42
Tests Analyzed: 127
Test Coverage Summary:
✅ Fully Tested: 28 requirements (66.7%)
⚠️ Partially Tested: 8 requirements (19.0%)
❌ Untested: 6 requirements (14.3%)
📊 Overall Coverage: 76.2%
Critical Test Gaps:
1. ❌ Payment Fraud Detection (High Risk)
• Requirement: RQ-042: "System shall detect suspicious payment patterns"
• Risk: Financial loss, regulatory compliance
• Test Gap: No fraud detection tests
• Priority: CRITICAL
• Recommendation: Add fraud detection test suite with edge cases
2. ⚠️ Payment Refund Processing (Medium Risk)
• Requirement: RQ-038: "System shall process refunds within 24 hours"
• Risk: Customer dissatisfaction, financial reconciliation
• Test Gap: Partial coverage (success cases only)
• Priority: HIGH
• Recommendation: Add failure scenarios, timeout tests, concurrency tests
3. ⚠️ Multi-Currency Support (Medium Risk)
• Requirement: RQ-035: "System shall support 15+ currencies"
• Risk: International expansion blocked
• Test Gap: Only 5 currencies tested
• Priority: MEDIUM
• Recommendation: Add remaining currency tests, exchange rate tests
4. ℹ️ Payment Receipt Generation (Low Risk)
• Requirement: RQ-041: "System shall generate PDF receipts"
• Risk: Minor user inconvenience
• Test Gap: No PDF validation tests
• Priority: LOW
• Recommendation: Add PDF generation and validation tests
Risk Analysis:
┌────────────────────┬──────────┬────────────┬──────────────┐
│ Risk Category │ Coverage│ Risk Level │ Action Needed│
├────────────────────┼──────────┼────────────┼──────────────┤
│ Security │ 40% │ HIGH │ ⚠️ Immediate │
│ Financial │ 75% │ MEDIUM │ 📅 Soon │
│ Compliance │ 90% │ LOW │ ℹ️ Optional │
│ User Experience │ 85% │ LOW │ ℹ️ Optional │
└────────────────────┴──────────┴────────────┴──────────────┘
Test Type Distribution:
• Unit Tests: 68 (53.5%)
• Integration Tests: 42 (33.1%)
• End-to-End Tests: 12 (9.4%)
• Performance Tests: 3 (2.4%)
• Security Tests: 2 (1.6%)
Test Effectiveness:
• Flaky Tests: 8 (6.3%)
• Slow Tests (>1s): 15 (11.8%)
• Unmaintained Tests: 5 (3.9%)
• High-Value Tests: 42 (33.1%)
Remediation Plan:
1. Week 1: Implement fraud detection tests (critical)
2. Week 2: Complete refund processing tests (high)
3. Week 3: Add missing currency tests (medium)
4. Week 4: Fix flaky tests, add PDF tests (low)
5. Ongoing: Test gap monitoring, prevention
Estimated Effort: 2-3 weeks
Target Coverage: 90% by 2026-03-19
テストギャップのJSON出力:
{
"analysis": {
"system": "payment-processing",
"timestamp": "2026-02-26T19:00:00Z",
"requirements_analyzed": 42,
"tests_analyzed": 127,
"coverage_percentage": 76.2
},
"coverage_summary": {
"fully_tested": 28,
"partially_tested": 8,
"untested": 6,
"coverage_by_type": {
"unit": 85.7,
"integration": 71.4,
"e2e": 42.9,
"performance": 14.3,
"security": 28.6
}
},
"test_gaps": [
{
"id": "gap-test-001",
"requirement_id": "RQ-042",
"requirement_description": "System shall detect suspicious payment patterns",
"gap_type": "missing_coverage",
"risk_level": "critical",
"business_impact": "high",
"technical_complexity": "high",
"user_exposure": "medium",
"test_types_needed": ["unit", "integration", "security"],
"recommended_tests": [
"Test fraud pattern detection",
"Test threshold-based alerts",
"Test false positive handling",
"Test integration with fraud service"
],
"priority_score": 92,
"priority_level": "critical",
"estimated_effort_hours": 16,
"owner": "security-qa-team"
},
{
"id": "gap-test-002",
"requirement_id": "RQ-038",
"requirement_description": "System shall process refunds within 24 hours",
"gap_type": "partial_coverage",
"existing_tests": 3,
"needed_tests": 8,
"missing_test_scenarios": [
"Refund timeout handling",
"Concurrent refund processing",
"Partial refund scenarios",
"Refund failure recovery"
],
"risk_level": "high",
"priority_score": 78,
"priority_level": "high",
"estimated_effort_hours": 8,
"owner": "payment-qa-team"
}
],
"risk_analysis": {
"high_risk_untested": 2,
"medium_risk_partial": 3,
"low_risk_gaps": 4,
"risk_coverage_score": 65.8
},
"test_effectiveness": {
"flaky_tests": 8,
"slow_tests": 15,
"unmaintained_tests": 5,
"high_value_tests": 42,
"effectiveness_score": 72.4
},
"recommendations": {
"immediate": [
"Implement fraud detection test suite",
"Review and fix flaky security tests"
],
"short_term": [
"Complete refund processing test coverage",
"Add missing currency tests"
],
"long_term": [
"Implement test gap monitoring",
"Improve test maintenance process"
]
}
}
テストカバレッジダッシュボード:
Test Coverage Dashboard
───────────────────────
Status: ACTIVE
Last Analysis: 2026-02-26 19:00:00
Next Analysis: 2026-02-27 07:00:00
Coverage Trends:
┌──────────────────────────────────────┐
│ Coverage Trend (Last 30 Days) │
│ │
│ 100 ┤ │
│ │ │
│ 90 ┤ │
│ │ █ │
│ 80 ┤ █ █ │
│ │ █ █ │
│ 70 ┤ ██ █ │
│ │ ██ █ │
│ 60 ┼───────██───────────█─────────│
│ 1 5 10 15 20 25 30 │
│ Days │
└──────────────────────────────────────┘
Current Coverage by Risk Category:
• Critical Security: 40% ⚠️
• High Business Impact: 75% ⚠️
• Medium Complexity: 88% ✅
• Low Risk: 95% ✅
Test Gap Distribution:
• Missing Coverage: 6 gaps
• Partial Coverage: 8 gaps
• Outdated Tests: 5 gaps
• Ineffective Tests: 8 gaps
Test Health Metrics:
• Flaky Test Rate: 6.3% (⚠️ Above threshold)
• Slow Test Rate: 11.8% (✅ Within limits)
• Test Maintenance Score: 72/100 (⚠️ Needs improvement)
• Test Value Score: 65/100 (⚠️ Needs improvement)
Alert Status:
⚠️ 2 critical test gaps aging > 7 days
⚠️ Flaky test rate above 5% threshold
✅ Overall coverage above 75% target
✅ High-risk coverage improving
Recommended Actions:
1. Address 2 critical test gaps
2. Reduce flaky test rate below 5%
3. Improve test maintenance score to 80+
4. Increase high-value test percentage
注意事項
- テストギャップ分析は責任追及が目的ではありません — 過失の所在を明らかにするのではなく、品質の向上に注力します
- テストカバレッジ100%が目標とは限りません — リスクに基づくテストの有効性に注力します
- テストギャップは品質リスクを示すものです — テストの失敗を示すものではありません
- 定期的なギャップ分析で蓄積を防ぎます — 大規模な監査よりも、小規模な分析を頻繁に行うほうが効果的です
- 関係者を巻き込みます — 開発者、QA、プロダクトマネージャーが協力してテストギャップの解消に取り組む必要があります
- リスクに基づいて優先順位を付けます — すべてのテストギャップが同じ重要度とは限りません
- ギャップの解消状況を追跡します — 時間の経過に伴うテストギャップ削減の進捗を測定します
- テストギャップ分析を先を見越して活用します — 問題の検出だけでなく、品質向上にも活用します
- 開発ワークフローに組み込みます — テストギャップ分析をテスト戦略に反映させます
- 分析プロセスを文書化します — 繰り返し実施し、改善できるようにします
- テストギャップの削減を称えます — テストカバレッジと品質の向上を評価します