mcpField
R
regression-testing

regression-testing

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

关于 regression-testing

用于代码变更后选择和运行回归测试的测试技能,面向开发者和 QA Agent,涵盖影响分析、优先级执行及测试套件健康检查。

主要功能

  1. 01按变更影响选择测试
  2. 02基于风险与历史排序
  3. 03按冒烟到完整套件执行
  4. 04并行运行与分片
  5. 05监控不稳定测试和耗时

适用场景

  1. 01为拉取请求选择测试
  2. 02规划每夜回归测试
  3. 03准备发布前完整测试
  4. 04将生产故障转为回归测试

安装

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

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

安装后在 Claude Code 中输入/regression-testing确认已加载。

包含的文件

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

evals/
regression-testing.yaml
schemas/
output.json
scripts/
validate-config.json

详细介绍

回归测试

<default_to_action> 验证变更不会破坏现有功能时:

  1. 分析变更内容(git diff、影响分析)
  2. 根据变更和风险选择测试(而非运行所有测试)
  3. 按优先级运行(冒烟测试 → 选择性测试 → 全量测试)
  4. 优化执行(并行、分片)
  5. 监控测试套件健康状况(不稳定性、执行时间)

快速回归策略:

  • 每次提交:冒烟测试 + 变更代码测试(5-10 分钟)
  • 每晚:扩展回归测试(30-60 分钟)
  • 发布前:全量回归测试(2-4 小时)

成功的关键因素:

  • 智能选择能用 10% 的时间捕获 90% 的回归问题
  • 不稳定的测试浪费的时间比节省的更多
  • 每个生产环境 bug 都要转化为回归测试 </default_to_action>

快速参考卡

适用场景
  • 任何代码变更后
  • 发布前
  • 依赖更新后
  • 环境变更后
测试选择策略
策略方法减少比例
基于变更Git diff 分析70-90%
基于风险按影响确定优先级50-70%
基于历史优先选择经常失败的测试40-60%
基于时间预算固定时间窗口不定

基于变更的测试选择

// Analyze changed files and select impacted tests
function selectTests(changedFiles: string[]): string[] {
  const testsToRun = new Set<string>();

  for (const file of changedFiles) {
    // Direct tests
    testsToRun.add(`${file.replace('.ts', '.test.ts')}`);

    // Dependent tests (via coverage mapping)
    const dependentTests = testCoverage[file] || [];
    dependentTests.forEach(t => testsToRun.add(t));
  }

  return Array.from(testsToRun);
}

// Example: payment.ts changed
// Runs: payment.test.ts, checkout.integration.test.ts, e2e/purchase.test.ts

CI/CD 集成

# .github/workflows/regression.yml
jobs:
  quick-regression:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - name: Analyze changes
        id: changes
        uses: dorny/paths-filter@v2
        with:
          filters: |
            payment:
              - 'src/payment/**'
            auth:
              - 'src/auth/**'

      - name: Run affected tests
        run: npm run test:affected

      - name: Smoke tests (always)
        run: npm run test:smoke

  nightly-regression:
    if: github.event_name == 'schedule'
    timeout-minutes: 120
    steps:
      - run: npm test -- --coverage

Agent 驱动的回归测试

// Smart test selection
await Task("Regression Analysis", {
  pr: 1234,
  strategy: 'change-based-with-risk',
  timeBudget: '15min'
}, "qe-regression-risk-analyzer");

// Returns:
// {
//   mustRun: ['payment.test.ts', 'checkout.integration.test.ts'],
//   shouldRun: ['order.test.ts'],
//   canSkip: ['profile.test.ts', 'search.test.ts'],
//   estimatedTime: '12 min',
//   riskCoverage: 0.94
// }

// Generate regression test from production bug
await Task("Bug Regression Test", {
  bug: { id: 'BUG-567', description: 'Checkout fails > 100 items' },
  preventRecurrence: true
}, "qe-test-generator");

Agent 协调提示

记忆命名空间
aqe/regression-testing/
├── test-selection/*     - Impact analysis results
├── suite-health/*       - Flakiness, timing trends
├── coverage-maps/*      - Test-to-code mapping
└── bug-regressions/*    - Tests from production bugs
Fleet 协调
const regressionFleet = await FleetManager.coordinate({
  strategy: 'comprehensive-regression',
  agents: [
    'qe-regression-risk-analyzer',  // Analyze changes, select tests
    'qe-test-executor',             // Execute selected tests
    'qe-coverage-analyzer',         // Analyze coverage gaps
    'qe-quality-gate'               // Go/no-go decision
  ],
  topology: 'sequential'
});

相关技能


请记住

使用 Agent: qe-regression-risk-analyzer 可智能选择测试,用 10% 的执行时间实现 90% 的缺陷检测率。Agent 会根据生产环境 bug 自动生成回归测试。

技能组合

  • 测试失败? → 使用 /test-failure-investigator 诊断根本原因
  • 提交 bug → 使用 /bug-reporting-excellence 规范地报告 bug
  • 选择测试 → 使用 /risk-based-testing 按风险确定优先级

注意事项

  • 即使被要求选择测试,Agent 仍可能默认“运行所有测试”——请使用 --affected 或文件列表明确限制范围
  • 基于变更的选择会遗漏传递依赖——模型变更可能导致 3 个跳转之外的控制器测试失败
  • 回归测试套件中的不稳定测试会比缺少测试更快地削弱信任——应立即将其隔离,而非跳过
  • 测试实际未运行时,Agent 也可能报告“0 个回归问题”——请核对输出中的测试数量,而不仅是通过/失败状态
  • 在容器中运行全量回归测试通常会导致内存不足——在 CI 环境中使用 --workers=2 和 --shard

评论

支持 Markdown