fix-tests

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Fix Tests

修复测试

User Arguments

用户参数

User can provide to focus on specific tests or modules:
$ARGUMENTS
If nothing is provided, focus on all tests.
用户可以提供以下内容以聚焦特定测试或模块:
$ARGUMENTS
如果未提供任何内容,则聚焦所有测试。

Context

背景

After business logic changes, refactoring, or dependency updates, tests may fail because they no longer match the current behavior or implementation. This command orchestrates automated fixing of all failing tests using specialized agents.
在业务逻辑变更、重构或依赖更新后,测试可能会失败,因为它们不再匹配当前的行为或实现。本命令通过专用Agent编排所有失败测试的自动化修复工作。

Goal

目标

Fix all failing tests to match current business logic and implementation.
修复所有失败的测试,使其与当前业务逻辑和实现保持一致。

Important Constraints

重要约束

  • Focus on fixing tests - avoid changing business logic unless absolutely necessary
  • Preserve test intent - ensure tests still validate the expected behavior
  • "Analyse complexity of changes" -
    • if there 2 or more changed files, or one file with complex logic, then Do not write tests yourself - only orchestrate agents!
    • if there is only one changed file, and it's a simple change, then you can write tests yourself.
  • 专注于修复测试 - 除非绝对必要,否则不要修改业务逻辑
  • 保留测试意图 - 确保测试仍能验证预期行为
  • "分析变更复杂度" -
    • 如果有2个或更多变更文件,或者单个文件包含复杂逻辑,则不要自行编写测试 - 仅编排Agent执行!
    • 如果只有一个变更文件,且变更简单,则可以自行编写测试。

Workflow Steps

工作流步骤

Preparation

准备阶段

  1. Read sadd skill if available
    • If available, read the sadd skill to understand best practices for managing agents
  2. Discover test infrastructure
    • Read @README.md and package.json (or equivalent project config)
    • Identify commands to run tests and coverage reports
    • Understand project structure and testing conventions
  3. Run all tests
    • Execute full test suite to establish baseline
  4. Identify all failing test files
    • Parse test output to get list of failing test files
    • Group by file for parallel agent execution
  1. 读取sadd技能(如果可用)
    • 如果可用,读取sadd技能以了解管理Agent的最佳实践
  2. 探索测试基础设施
    • 读取@README.md和package.json(或等效项目配置文件)
    • 确定运行测试和生成覆盖率报告的命令
    • 了解项目结构和测试约定
  3. 运行所有测试
    • 执行完整测试套件以建立基准
  4. 识别所有失败的测试文件
    • 解析测试输出以获取失败测试文件列表
    • 按文件分组以便Agent并行执行

Analysis

分析阶段

  1. Verify single test execution
    • Choose any test file
    • Launch haiku agent with instructions to find proper command to run this only test file
      • Ask him to iterate until you can reliably run individual tests
    • After he complete try running a specific test file if it exists
    • This ensures agents can run tests in isolation
  1. 验证单个测试执行
    • 选择任意测试文件
    • 启动haiku Agent并指示其找到运行该单个测试文件的正确命令
      • 要求其反复尝试,直到能够可靠地运行单个测试
    • 完成后尝试运行特定测试文件(如果存在)
    • 确保Agent可以独立运行测试

Test Fixing

测试修复

  1. Launch
    developer
    agents (parallel)
    • Launch one agent per failing test file
    • Provide each agent with clear instructions:
      • Context: Why this test needs fixing (business logic changed)
      • Target: Which specific file to fix
      • Guidance: Read TDD skill (if available) for best practices how to write tests.
      • Resources: Read README and relevant documentation
      • Command: How to run this specific test file
      • Goal: Iterate until test passes
      • Constraint: Fix test, not business logic (unless clearly broken)
  2. Verify all fixes
    • After all agents complete, run full test suite again
    • Verify all tests pass
  3. Iterate if needed
    • If any tests still fail: Return to step 5
    • Launch new agents only for remaining failures
    • Continue until 100% pass rate
  1. 并行启动
    developer
    Agent
    • 为每个失败的测试文件启动一个Agent
    • 为每个Agent提供明确指示:
      • 背景:该测试需要修复的原因(业务逻辑已变更)
      • 目标:需要修复的特定文件
      • 指导:读取TDD技能(如果可用)以了解编写测试的最佳实践
      • 资源:读取README和相关文档
      • 命令:运行该特定测试文件的方法
      • 目标:反复尝试直到测试通过
      • 约束:修复测试,而非业务逻辑(除非明确存在bug)
  2. 验证所有修复
    • 所有Agent完成后,再次运行完整测试套件
    • 验证所有测试通过
  3. 必要时迭代
    • 如果仍有测试失败:返回步骤5
    • 仅为剩余失败的测试启动新Agent
    • 持续迭代直到测试通过率达到100%

Success Criteria

成功标准

  • All tests pass ✅
  • Test coverage maintained
  • Test intent preserved
  • Business logic unchanged (unless bugs found)
  • 所有测试通过 ✅
  • 测试覆盖率得以保持
  • 测试意图得以保留
  • 业务逻辑未变更(除非发现bug)

Agent Instructions Template

Agent指令模板

When launching agents, use this template:
The business logic has changed and test file {FILE_PATH} is now failing.

Your task:
1. Read the test file and understand what it's testing
2. Read TDD skill (if available) for best practices on writing tests.
3. Read @README.md for project context
4. Run the test: {TEST_COMMAND}
5. Analyze the failure - is it:
   - Test expectations outdated? → Fix test assertions
   - Test setup broken? → Fix test setup/mocks
   - Business logic bug? → Fix logic (rare case)
6. Fix the test and verify it passes
7. Iterate until test passes
启动Agent时,请使用以下模板:
业务逻辑已变更,测试文件 {FILE_PATH} 现在执行失败。

你的任务:
1. 读取测试文件并理解其测试内容
2. 读取TDD技能(如果可用)以了解编写测试的最佳实践
3. 读取@README.md以获取项目背景
4. 运行测试:{TEST_COMMAND}
5. 分析失败原因:
   - 测试预期已过时?→ 修复测试断言
   - 测试设置已损坏?→ 修复测试设置/模拟
   - 业务逻辑存在bug?→ 修复逻辑(罕见情况)
6. 修复测试并验证其通过
7. 反复尝试直到测试通过