mcpField
Q
qe-regression-testing

qe-regression-testing

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

关于 qe-regression-testing

面向软件测试人员的回归测试技能,指导根据代码变更和风险挑选测试,并按优先级运行、优化执行和监控套件健康状况。

主要功能

  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 qe-regression-testing

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

详细介绍

回归测试

<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

回归测试金字塔

         /\
        /  \  Full Regression (weekly)
       /    \  - All tests (2-4 hours)
      /------\
     /        \  Extended Regression (nightly)
    /          \  - Unit + integration + critical E2E (30-60 min)
   /------------\
  /              \  Quick Regression (per commit)
 /________________\  - Changed code + smoke tests (5-10 min)

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

优化技术

// 1. Parallel execution
module.exports = {
  maxWorkers: '50%', // Use half CPU cores
  testTimeout: 30000
};

// 2. Sharding across CI workers
// npm test -- --shard=1/4

// 3. Incremental testing (only changed since last run)
// Track last run state, skip passing unchanged tests

// 4. Fast-fail on smoke
// Run critical tests first, abort if they fail

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
集群协作
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 自动生成回归测试。

评论

支持 Markdown