test-gap-analysis

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Test Gap Analysis

测试差距分析

Identify discrepancies between requirements/features that should be tested and actual test coverage through systematic analysis of testing completeness, effectiveness, and risk coverage to improve software quality and reliability.
通过对测试完整性、有效性和风险覆盖范围的系统性分析,识别应测试的需求/功能与实际测试覆盖范围之间的差异,以提升软件质量和可靠性。

When to use me

适用场景

Use this skill when:
  • Uncertainty exists about what parts of the system are adequately tested
  • New features have been added without corresponding test coverage
  • Testing resources are limited and need optimal allocation
  • Preparing for releases or deployments with confidence in test coverage
  • Auditing testing effectiveness for compliance or quality standards
  • Identifying high-risk areas with insufficient testing
  • Planning test automation or test improvement initiatives
  • Onboarding new team members to understand test coverage
  • Assessing technical debt in testing infrastructure
  • Validating that critical functionality has appropriate test protection
在以下场景中使用本技能:
  • 不确定系统哪些部分已得到充分测试
  • 新增功能未配备对应的测试覆盖
  • 测试资源有限,需要优化分配
  • 为版本发布或部署做准备,确保测试覆盖足够可靠
  • 为合规或质量标准审核测试有效性
  • 识别测试不足的高风险区域
  • 规划测试自动化或测试改进计划
  • 帮助新团队成员了解测试覆盖情况
  • 评估测试基础设施中的技术债务
  • 验证关键功能是否具备适当的测试防护

What I do

核心功能

1. Requirements Testability Analysis

1. 需求可测试性分析

  • Analyze requirements for testability: Identify testable aspects of each requirement
  • Extract test conditions and scenarios from requirements documentation
  • Categorize requirements by test type: Unit, integration, system, acceptance, performance, security
  • Assess requirement clarity for testing: Ambiguous vs. testable requirements
  • Identify implicit requirements that should be tested but aren't documented
  • 分析需求的可测试性:识别每个需求中可测试的部分
  • 从需求文档中提取测试条件和场景
  • 按测试类型对需求分类:Unit, integration, system, acceptance, performance, security
  • 评估需求的测试清晰度:区分模糊需求与可测试需求
  • 识别未记录但应测试的隐含需求

2. Test Coverage Analysis

2. 测试覆盖范围分析

  • Analyze existing test suites: Unit tests, integration tests, end-to-end tests, manual tests
  • Map tests to requirements: Determine which requirements have test coverage
  • Measure coverage metrics: Line coverage, branch coverage, requirement coverage, risk coverage
  • Identify test gaps: Requirements without tests, partial coverage, outdated tests
  • Assess test effectiveness: Test quality, flakiness, maintenance burden
  • 分析现有测试套件:Unit tests, integration tests, end-to-end tests, manual tests
  • 将测试与需求关联:确定哪些需求已被测试覆盖
  • 衡量覆盖指标:代码行覆盖率、分支覆盖率、需求覆盖率、风险覆盖率
  • 识别测试差距:无测试覆盖的需求、部分覆盖的需求、过时的测试
  • 评估测试有效性:测试质量、不稳定测试、维护成本

3. Gap Identification & Classification

3. 差距识别与分类

  • Missing test coverage: Requirements with no corresponding tests
  • Incomplete test coverage: Requirements with partial test coverage
  • Outdated tests: Tests that don't match current requirements
  • Ineffective tests: Tests that don't adequately validate requirements
  • Risk coverage gaps: High-risk areas with insufficient testing
  • Test type gaps: Missing test types (security, performance, accessibility)
  • 缺失的测试覆盖:无对应测试的需求
  • 不完整的测试覆盖:仅部分被测试覆盖的需求
  • 过时的测试:与当前需求不匹配的测试
  • 无效的测试:无法充分验证需求的测试
  • 风险覆盖差距:测试不足的高风险区域
  • 测试类型差距:缺失的测试类型(安全、性能、可访问性等)

4. Risk-Based Prioritization

4. 基于风险的优先级排序

  • Assess business impact of untested requirements
  • Evaluate technical risk of inadequate testing
  • Calculate test gap severity based on impact and likelihood
  • Prioritize test gaps for remediation planning
  • Estimate effort to address each test gap
  • Recommend test strategy based on risk profile
  • 评估未测试需求的业务影响
  • 评估测试不足的技术风险
  • 基于影响和可能性计算测试差距的严重程度
  • 确定测试差距的修复优先级
  • 估算解决每个测试差距所需的工作量
  • 基于风险状况推荐测试策略

5. Test Improvement Recommendations

5. 测试改进建议

  • Generate specific test cases to address gaps
  • Recommend test types and approaches for each gap
  • Suggest test automation opportunities
  • Propose test infrastructure improvements
  • Design test data strategies for uncovered scenarios
  • Create test maintenance plans to prevent future gaps
  • 生成针对差距的具体测试用例
  • 为每个差距推荐测试类型和方法
  • 提出测试自动化的机会
  • 建议测试基础设施的改进方案
  • 为未覆盖的场景设计测试数据策略
  • 制定测试维护计划以避免未来出现差距

Test Gap Types

测试差距类型

1. Coverage Gaps

1. 覆盖范围差距

Missing Test Coverage: Requirements with no tests at all
Partial Test Coverage: Requirements with incomplete test coverage
Example: Authentication requirement tested for success but not failure cases
缺失的测试覆盖:完全没有测试的需求
不完整的测试覆盖:仅部分被测试覆盖的需求
示例:身份验证需求仅测试了成功场景,未测试失败场景

2. Type Gaps

2. 测试类型差距

Missing Test Types: Critical test types not represented (security, performance, etc.)
Inappropriate Test Types: Wrong test type for requirement (unit vs. integration)
Example: Performance-critical feature only has unit tests, no performance tests
缺失的测试类型:未包含关键测试类型(安全、性能等)
不恰当的测试类型:使用了不适合需求的测试类型(单元测试 vs 集成测试)
示例:对性能敏感的功能仅进行了单元测试,未做性能测试

3. Effectiveness Gaps

3. 有效性差距

Ineffective Tests: Tests that don't adequately validate requirements
Flaky Tests: Unreliable tests that provide false confidence
Example: Test passes but doesn't actually validate the requirement
无效的测试:无法充分验证需求的测试
不稳定测试:不可靠的测试,会带来虚假的安全感
示例:测试通过但并未实际验证需求

4. Maintenance Gaps

4. 维护差距

Outdated Tests: Tests that don't match current requirements
Unmaintained Tests: Tests that fail frequently but aren't fixed
Example: Tests for deprecated functionality still in test suite
过时的测试:与当前需求不匹配的测试
未维护的测试:频繁失败但未被修复的测试
示例:测试套件中仍包含针对已弃用功能的测试

5. Risk Coverage Gaps

5. 风险覆盖差距

High-Risk Untested: Critical functionality without adequate testing
Low-Risk Overtested: Non-critical functionality with excessive testing
Example: Payment processing with minimal tests but UI with extensive tests
高风险未测试:关键功能未得到充分测试
低风险过度测试:非关键功能被过度测试
示例:支付处理功能测试极少,但UI功能测试详尽

Analysis Techniques

分析技术

Requirements Test Extraction

需求测试提取

python
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
python
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

Test Coverage Mapping

测试覆盖映射

python
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
python
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

Risk-Based Gap Prioritization

基于风险的差距优先级排序

python
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
python
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

Examples

示例

bash
undefined
bash
undefined

Analyze test coverage gaps

分析测试覆盖差距

npm run test-gap-analysis:analyze -- --requirements specs/ --tests tests/ --output gaps.json
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
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
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
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
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
undefined
npm run test-gap-analysis:monitor -- --watch --requirements specs/ --tests tests/ --alert-on-gap
undefined

Output format

输出格式

Test Gap Analysis Report:

测试差距分析报告:

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
测试差距分析报告
────────────────────────
系统: 支付处理服务
分析日期: 2026-02-26
分析的需求数量: 42
分析的测试数量: 127

测试覆盖摘要:
✅ 完全测试: 28个需求 (66.7%)
⚠️ 部分测试: 8个需求 (19.0%)
❌ 未测试: 6个需求 (14.3%)
📊 总体覆盖率: 76.2%

关键测试差距:

1. ❌ 支付欺诈检测 (高风险)
   • 需求: RQ-042: "系统应检测可疑支付模式"
   • 风险: 财务损失、合规风险
   • 测试差距: 无欺诈检测测试
   • 优先级: CRITICAL
   • 建议: 添加包含边缘场景的欺诈检测测试套件

2. ⚠️ 支付退款处理 (中风险)
   • 需求: RQ-038: "系统应在24小时内处理退款"
   • 风险: 客户不满、财务对账问题
   • 测试差距: 部分覆盖(仅测试成功场景)
   • 优先级: HIGH
   • 建议: 添加失败场景、超时测试、并发测试

3. ⚠️ 多币种支持 (中风险)
   • 需求: RQ-035: "系统应支持15+种货币"
   • 风险: 国际扩张受阻
   • 测试差距: 仅测试了5种货币
   • 优先级: MEDIUM
   • 建议: 添加剩余货币的测试、汇率测试

4. ℹ️ 支付收据生成 (低风险)
   • 需求: RQ-041: "系统应生成PDF收据"
   • 风险: 轻微用户不便
   • 测试差距: 无PDF验证测试
   • 优先级: LOW
   • 建议: 添加PDF生成和验证测试

风险分析:
┌────────────────────┬──────────┬────────────┬──────────────┐
│ 风险类别           │ 覆盖率  │ 风险等级   │ 所需行动     │
├────────────────────┼──────────┼────────────┼──────────────┤
│ 安全               │ 40%      │ 高         │ ⚠️ 立即处理   │
│ 财务               │ 75%      │ 中         │ 📅 尽快处理   │
│ 合规               │ 90%      │ 低         │ ℹ️ 可选处理   │
│ 用户体验           │ 85%      │ 低         │ ℹ️ 可选处理   │
└────────────────────┴──────────┴────────────┴──────────────┘

测试类型分布:
• 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%)

测试有效性:
• 不稳定测试: 8 (6.3%)
• 慢测试(>1s): 15 (11.8%)
• 未维护测试: 5 (3.9%)
• 高价值测试: 42 (33.1%)

修复计划:
1. 第1周: 实施欺诈检测测试(关键)
2. 第2周: 完成退款处理测试(高优先级)
3. 第3周: 添加缺失的货币测试(中优先级)
4. 第4周: 修复不稳定测试,添加PDF测试(低优先级)
5. 持续进行: 测试差距监控、预防

估算工作量: 2-3周
目标覆盖率: 截至2026-03-19达到90%

Test Gap JSON Output:

测试差距JSON输出:

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"
    ]
  }
}
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:

测试覆盖仪表盘:

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
测试覆盖仪表盘
───────────────────────
状态: 活跃
上次分析时间: 2026-02-26 19:00:00
下次分析时间: 2026-02-27 07:00:00

覆盖趋势:
┌──────────────────────────────────────┐
│ 覆盖趋势(过去30天)                │
│                                      │
│ 100 ┤                               │
│     │                               │
│  90 ┤                               │
│     │                █              │
│  80 ┤               █ █             │
│     │              █   █            │
│  70 ┤            ██     █           │
│     │          ██        █          │
│  60 ┼───────██───────────█─────────│
│       1   5   10   15   20   25   30 │
│                 天数                 │
└──────────────────────────────────────┘

按风险类别划分的当前覆盖率:
• 关键安全需求: 40% ⚠️
• 高业务影响需求: 75% ⚠️
• 中复杂度需求: 88% ✅
• 低风险需求: 95% ✅

测试差距分布:
• 缺失覆盖: 6个差距
• 部分覆盖: 8个差距
• 过时测试: 5个差距
• 无效测试: 8个差距

测试健康指标:
• 不稳定测试率: 6.3% (⚠️ 超过阈值)
• 慢测试率: 11.8% (✅ 在允许范围内)
• 测试维护得分: 72/100 (⚠️ 需要改进)
• 测试价值得分: 65/100 (⚠️ 需要改进)

告警状态:
⚠️  2个关键测试差距已超过7天
⚠️  不稳定测试率超过5%阈值
✅  总体覆盖率超过75%目标
✅  高风险需求覆盖率正在提升

建议行动:
1. 处理2个关键测试差距
2. 将不稳定测试率降至5%以下
3. 将测试维护得分提升至80+
4. 提高高价值测试的占比

Notes

注意事项

  • Test gap analysis is not about blame - focus on improving quality, not assigning fault
  • 100% test coverage is rarely the goal - focus on risk-based testing effectiveness
  • Test gaps indicate quality risks - not testing failures
  • Regular gap analysis prevents accumulation - small, frequent analyses better than large audits
  • Involve stakeholders - developers, QA, product managers should collaborate on test gap resolution
  • Prioritize based on risk - not all test gaps are equally important
  • Track gap closure - measure progress in reducing test gaps over time
  • Use test gap analysis proactively - not just for problem detection but for quality improvement
  • Integrate with development workflow - test gap analysis should inform testing strategy
  • Document the analysis process - so it can be repeated and improved
  • Celebrate test gap reduction - recognize improvements in test coverage and quality
  • 测试差距分析不是为了追责 - 重点是提升质量,而非归咎责任
  • 100%测试覆盖很少是目标 - 重点是基于风险的测试有效性
  • 测试差距代表质量风险 - 而非测试失败
  • 定期进行差距分析可避免问题累积 - 频繁的小型分析比大型审核更有效
  • 让相关人员参与 - 开发人员、QA、产品经理应协作解决测试差距
  • 基于风险确定优先级 - 并非所有测试差距都同等重要
  • 跟踪差距修复进度 - 衡量随时间推移测试差距的减少情况
  • 主动使用测试差距分析 - 不仅用于问题检测,还用于质量提升
  • 与开发工作流集成 - 测试差距分析应指导测试策略
  • 记录分析流程 - 以便重复执行和改进
  • 庆祝测试差距的减少 - 认可测试覆盖和质量的提升