mcpField
Q
qe-defect-intelligence

qe-defect-intelligence

github.com/proffesor-for-testing测试与质量51994 次安装今天更新
代码仓库

关于 qe-defect-intelligence

qe-defect-intelligence 是面向测试团队的技能,可预测缺陷风险、归纳历史缺陷模式并分析根因,结合代码变更因素与结构化 RCA 方法。

主要功能

  1. 01根据代码变更预测缺陷
  2. 02学习历史缺陷模式
  3. 03使用多种根因分析方法
  4. 04提供风险分数及影响因素
  5. 05与问题跟踪器同步

适用场景

  1. 01确定高风险拉取请求的评审优先级
  2. 02发现反复出现的失败模式
  3. 03调查测试失败的原因

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill qe-defect-intelligence

安装后在 Claude Code 中输入/qe-defect-intelligence确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

evals/
qe-defect-intelligence.yaml
schemas/
output.json
scripts/
validate-config.json

详细介绍

QE 缺陷智能

用途

指导使用 v3 的缺陷智能能力,包括基于 ML 的缺陷预测、从历史数据中识别模式,以及自动化根因分析。

启用场景

  • 预测易出现缺陷的代码
  • 分析故障模式
  • 执行根因分析
  • 从过往缺陷中学习
  • 基于风险确定测试优先级

快速入门

# Predict defects in changed code
aqe defect predict --changes HEAD~5..HEAD

# Analyze failure patterns
aqe defect patterns --period 90d --min-occurrences 3

# Root cause analysis
aqe defect rca --failure "test/auth.test.ts:45"

# Learn from resolved defects
aqe defect learn --source jira --status resolved

Agent 工作流

// Defect prediction
Task("Predict defect-prone code", `
  Analyze PR #456 changes and predict defect likelihood:
  - Historical defect correlation
  - Code complexity factors
  - Author experience with module
  - Test coverage gaps
  Flag high-risk changes requiring extra review.
`, "qe-defect-predictor")

// Root cause analysis
Task("Analyze test failure", `
  Investigate recurring failure in AuthService tests:
  - Collect failure history (last 30 days)
  - Identify common patterns
  - Trace to potential root causes
  - Suggest fixes using 5-whys analysis
`, "qe-root-cause-analyzer")

预测模型

1. 基于变更的预测
await defectPredictor.predictFromChanges({
  changes: prChanges,
  factors: {
    codeChurn: { weight: 0.2 },
    complexity: { weight: 0.25 },
    authorExperience: { weight: 0.15 },
    fileHistory: { weight: 0.2 },
    testCoverage: { weight: 0.2 }
  },
  threshold: {
    high: 0.7,
    medium: 0.4,
    low: 0.2
  }
});
2. 模式学习
await patternLearner.learnPatterns({
  source: {
    defects: 'jira:project=MYAPP&type=bug',
    commits: 'git:last-6-months',
    tests: 'test-results:last-1000-runs'
  },
  patterns: [
    'code-smell-to-defect',
    'change-coupling',
    'test-gap-correlation',
    'complexity-defect-density'
  ],
  output: {
    rules: true,
    visualizations: true,
    recommendations: true
  }
});
3. 根因分析
await rootCauseAnalyzer.analyze({
  failure: testFailure,
  methods: [
    'five-whys',
    'fishbone-diagram',
    'fault-tree',
    'change-impact'
  ],
  context: {
    recentChanges: true,
    environmentDiff: true,
    dependencyChanges: true,
    similarFailures: true
  }
});

缺陷预测报告

interface DefectPrediction {
  file: string;
  riskScore: number;  // 0-1
  riskLevel: 'critical' | 'high' | 'medium' | 'low';
  factors: {
    name: string;
    contribution: number;
    details: string;
  }[];
  historicalDefects: {
    count: number;
    recent: Defect[];
    patterns: string[];
  };
  recommendations: {
    action: string;
    priority: string;
    expectedRiskReduction: number;
  }[];
}

模式类别

模式检测方法预防措施
空指针静态分析空值检查、Optional
竞态条件并发分析锁、原子操作
内存泄漏堆分析资源清理
差一错误边界分析循环不变式
注入污点分析输入验证

根因模板

root_cause_analysis:
  five_whys:
    max_depth: 5
    prompt_template: "Why did {effect} happen?"

  fishbone:
    categories:
      - people
      - process
      - tools
      - environment
      - materials
      - measurement

  fault_tree:
    top_event: "Test Failure"
    gate_types: [AND, OR, NOT]
    basic_events: true

与问题跟踪的集成

await defectIntelligence.syncWithTracker({
  source: 'jira',
  project: 'MYAPP',
  sync: {
    defectData: 'bidirectional',
    predictions: 'create-tasks',
    patterns: 'update-labels'
  },
  automation: {
    flagHighRisk: true,
    suggestAssignee: true,
    linkRelated: true
  }
});

协作

主要 Agent:qe-defect-predictor、qe-pattern-learner、qe-root-cause-analyzer 协调器:qe-defect-intelligence-coordinator 相关技能:qe-coverage-analysis、qe-quality-assessment

评论

支持 Markdown