parallel-test-fixing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseParallel Test Fixing
并行测试修复
Speed up fixing a broken test suite by distributing failing tests across parallel subagents.
通过将失败的测试分配给并行的Subagent,加速修复损坏的测试套件。
Workflow
工作流程
1. Run the Full Test Suite
1. 运行完整测试套件
bash
npm test -- --no-coverage 2>&1 || trueCapture the output and extract all failing test files.
bash
npm test -- --no-coverage 2>&1 || true捕获输出并提取所有失败的测试文件。
2. Group Failures
2. 分组故障
Parse the test output for failing files:
- Jest:
FAIL src/components/Button.test.tsx - Vitest:
FAIL src/utils/format.test.ts - Pytest:
FAILED tests/test_api.py::test_create_user
Group by file — each file becomes one task.
解析测试输出以找出失败文件:
- Jest:
FAIL src/components/Button.test.tsx - Vitest:
FAIL src/utils/format.test.ts - Pytest:
FAILED tests/test_api.py::test_create_user
按文件分组——每个文件对应一个任务。
3. Launch Parallel Subagents
3. 启动并行Subagent
For each failing test file, launch a subagent:
generalPurposeTask: Fix the failing tests in <file>
The test file is: <path>
The test command is: <command to run just this file>
The error output was:
<paste the relevant failure output>
Steps:
1. Read the test file and the source file it tests
2. Understand why each test is failing
3. Fix the source code (preferred) or update the test if the test is wrong
4. Run the single test file to confirm it passes
5. Report what you changed and whyLaunch all subagents simultaneously — they work in parallel since each touches different files.
针对每个失败的测试文件,启动一个 Subagent:
generalPurpose任务:修复<file>中的失败测试
测试文件路径:<path>
测试命令:<command to run just this file>
错误输出如下:
<paste the relevant failure output>
步骤:
1. 阅读测试文件及其测试的源文件
2. 理解每个测试失败的原因
3. 修复源代码(优先选择)或更新测试(如果测试本身有误)
4. 运行单个测试文件以确认其通过
5. 报告所做的更改及原因同时启动所有Subagent——由于它们各自处理不同的文件,因此会并行工作。
4. Collect Results
4. 收集结果
As each subagent completes, collect:
- Which tests were fixed
- What files were changed
- Whether the fix might conflict with another subagent's changes
每个Subagent完成后,收集以下信息:
- 哪些测试已修复
- 修改了哪些文件
- 该修复是否可能与其他Subagent的更改产生冲突
5. Verify
5. 验证
Run the full test suite one more time to confirm everything passes:
bash
npm testIf there are new failures (from conflicting fixes), resolve them sequentially.
再次运行完整测试套件以确认所有测试通过:
bash
npm test如果出现新的失败(由冲突修复导致),则依次解决这些问题。
Tips
提示
- If two failing tests share the same source file, assign them to the same subagent to avoid edit conflicts
- Set a timeout — if a subagent is stuck for 5+ minutes, check its progress
- For large test suites (50+ failures), batch into groups of 5-10 per subagent rather than one-per-file
- Use subagents if you want isolated worktrees for each fix attempt
best-of-n-runner
- 如果两个失败的测试共享同一个源文件,将它们分配给同一个Subagent以避免编辑冲突
- 设置超时时间——如果Subagent卡住超过5分钟,检查其进度
- 对于大型测试套件(50+个失败案例),将其分批为每个Subagent处理5-10个案例,而不是每个文件一个
- 如果希望为每个修复尝试使用独立的工作树,请使用Subagent
best-of-n-runner