QE覆盖分析Skill "QECoverageAnalysis"

QE覆盖分析技能用于检测软件测试中的覆盖差距,使用O(log n)次线性算法提高效率,结合风险加权分析评估代码风险,并智能优先级排序测试工作,以优化软件质量。关键词:测试覆盖、风险分析、优先级排序、代码质量、QE覆盖。

测试 0 次安装 2 次浏览 更新于 3/9/2026

名称: “QE覆盖分析” 描述: “使用O(log n)次线性覆盖差距检测,结合风险加权分析和智能测试优先级排序。” 信任等级: 3 验证: 模式路径: schemas/output.json 验证器路径: scripts/validate-config.json 评估路径: evals/qe-coverage-analysis.yaml


QE覆盖分析

目的

指导使用v3的高级覆盖分析能力,包括次线性差距检测算法、风险加权覆盖评分和基于代码关键性的智能测试优先级排序。

激活

  • 当分析测试覆盖时
  • 当识别覆盖差距时
  • 当优先排序测试工作时
  • 当设置覆盖目标时
  • 当评估代码风险时

快速开始

# 使用差距检测分析覆盖
aqe coverage analyze --source src/ --tests tests/

# 查找高风险未覆盖代码
aqe coverage gaps --risk-weighted --threshold 80

# 生成覆盖报告
aqe coverage report --format html --output coverage-report/

# 比较分支间的覆盖
aqe coverage diff --base main --head feature-branch

代理工作流

// 全面覆盖分析
Task("分析覆盖差距", `
  在src/上执行O(log n)覆盖分析:
  - 计算语句、分支、函数覆盖
  - 识别未覆盖的关键路径
  - 根据代码复杂度和变更频率风险加权差距
  - 推荐编写测试以实现最大覆盖影响
`, "qe-coverage-specialist")

// 基于风险的优先级排序
Task("优先排序覆盖工作", `
  分析覆盖差距并根据以下因素优先排序:
  - 业务关键性(支付、认证、数据)
  - 代码复杂度(圈复杂度 > 10)
  - 最近错误历史
  - 变更频率
  输出需要测试的文件优先级列表。
`, "qe-coverage-analyzer")

分析策略

1. 次线性差距检测

await coverageAnalyzer.detectGaps({
  algorithm: 'sublinear',  // O(log n) 复杂度
  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,           // 新代码必须有80%覆盖
    modifiedCode: 'maintain',  // 不要降低现有覆盖
    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: "数据库迁移"
    - path: "src/generated/**"
      reason: "自动生成代码"

覆盖报告

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  # 连续PRs

协调

主要代理: qe-coverage-specialist, qe-coverage-analyzer, qe-gap-detector 协调员: qe-coverage-coordinator 相关技能: qe-test-generation, qe-quality-assessment