Loading...
Loading...
Compare original and translation side by side
test-driven-developmenttest-driven-developmentsystematic-refactoringtest-driven-developmentsystematic-refactoringtest-driven-development*_test.gotest_*.py*_test.py*.test.ts*.spec.ts*.test.js*.spec.jsreferences/anti-pattern-catalog.md| # | Anti-Pattern | Detection Signal |
|---|---|---|
| 1 | Testing implementation details | Asserts on private fields, internal regex, spy on private methods |
| 2 | Over-mocking / brittle selectors | Mock setup > 50% of test code, CSS nth-child selectors |
| 3 | Order-dependent tests | Shared mutable state, class-level variables, numbered test names |
| 4 | Incomplete assertions | |
| 5 | Over-specification | Exact timestamps, hardcoded IDs, asserting every default field |
| 6 | Ignored failures | |
| 7 | Poor naming | |
| 8 | Missing edge cases | Only happy path, no empty/null/boundary/error tests |
| 9 | Slow test suites | Full DB reset per test, no parallelization, no fixture sharing |
| 10 | Flaky tests | |
undefined*_test.gotest_*.py*_test.py*.test.ts*.spec.ts*.test.js*.spec.jsreferences/anti-pattern-catalog.md| 序号 | 反模式 | 检测信号 |
|---|---|---|
| 1 | 测试实现细节 | 断言私有字段、内部正则表达式、监听私有方法 |
| 2 | 过度Mock / 脆弱选择器 | Mock代码占测试代码的50%以上、使用CSS nth-child选择器 |
| 3 | 依赖执行顺序的测试 | 共享可变状态、类级变量、带编号的测试名称 |
| 4 | 不完整的断言 | |
| 5 | 过度指定 | 断言精确时间戳、硬编码ID、断言所有默认字段 |
| 6 | 忽略失败 | |
| 7 | 命名不佳 | |
| 8 | 缺失边界用例 | 仅覆盖正常路径,无空值/空输入/边界/错误场景测试 |
| 9 | 缓慢的测试套件 | 每次测试重置完整数据库、未并行化、未共享测试夹具 |
| 10 | 不稳定测试 | |
undefined
**Gate**: At least one anti-pattern identified with file:line reference. Proceed only when gate passes.
**准入条件**:至少识别出一个带文件:行号引用的反模式。仅当满足条件时继续下一步。ANTI-PATTERN: [Name]
Location: [file:line]
Issue: [What is wrong]
Impact: [Flaky/slow/false-confidence/maintenance burden]
Current:
[problematic code snippet]
Fixed:
[improved code snippet]
Priority: [HIGH/MEDIUM/LOW]references/fix-strategies.md反模式: [名称]
位置: [文件:行号]
问题: [具体错误内容]
影响: [不稳定/缓慢/错误信心/维护负担]
当前代码:
[有问题的代码片段]
修复后代码:
[改进后的代码片段]
优先级: [HIGH/MEDIUM/LOW]references/fix-strategies.mdgo test -count=3 -run TestFixed ./...pytest --count=3 tests/test_fixed.py@skip.skipundefinedgo test -count=3 -run TestFixed ./...pytest --count=3 tests/test_fixed.py@skip.skipundefined
**Gate**: Full suite passes. All fixes verified. Summary delivered.
---
**准入条件**:完整套件测试通过。所有修复均已验证。已交付总结报告。
---sleep(500)sleep()waitFor()sleep(500)waitFor()sleep()!= niltoBeTruthy!= niltoBeTruthy@skip.skipxit@pytest.mark.skip@skip.skipxit@pytest.mark.skiptest1test_creates_usertest1test_creates_user| Anti-Pattern | Symptom | Fix |
|---|---|---|
| Testing implementation | Test breaks on refactor | Test behavior, not internals |
| Over-mocking | Mock setup > test logic | Integration test or mock only I/O |
| Order dependence | Tests fail in isolation | Each test owns its data |
| Incomplete assertions | | Assert specific expected values |
| Over-specification | Asserts on defaults/timestamps | Assert only what matters for this test |
| Ignored failures | | Delete or fix immediately |
| Poor naming | | |
| Missing edge cases | Only happy path | empty, null, boundary, error, large |
| Slow suite | 30s+ for simple tests | Parallelize, share fixtures, rollback |
| Flaky tests | Random failures | Control time, synchronize, no sleep |
| 反模式 | 症状 | 修复方案 |
|---|---|---|
| 测试实现细节 | 重构时测试失败 | 测试行为而非内部实现 |
| 过度Mock | Mock代码多于测试逻辑 | 改用集成测试或仅在I/O边界Mock |
| 依赖执行顺序 | 单独运行测试失败 | 每个测试拥有独立的数据 |
| 不完整断言 | | 断言具体的预期值 |
| 过度指定 | 断言默认值/时间戳 | 仅断言对本测试重要的内容 |
| 忽略失败 | | 立即删除或修复 |
| 命名不佳 | | 使用 |
| 缺失边界用例 | 仅覆盖正常路径 | 添加空值、null、边界、错误、大输入等用例 |
| 缓慢的套件 | 简单测试耗时30秒以上 | 并行化、共享夹具、回滚 |
| 不稳定测试 | 随机失败 | 控制时间、同步、不使用sleep |
@skip@ignorexit.skiptime.sleep()setTimeout()test1test2!= nil> 0toBeTruthy()@skip@ignorexit.skiptime.sleep()setTimeout()test1test2!= nil> 0toBeTruthy()| Rationalization | Why It's Wrong | Required Action |
|---|---|---|
| "The test passes, so it's fine" | Passing with anti-patterns gives false confidence | Evaluate assertion quality, not just pass/fail |
| "We can fix test quality later" | Anti-patterns compound; flaky tests erode trust daily | Fix HIGH severity items now, defer LOW |
| "Just skip the flaky test for now" | Skipped tests become permanent blind spots | Diagnose root cause, fix or delete |
| "Mocking everything is faster" | Over-mocking tests mock wiring, not behavior | Mock only at architectural boundaries |
| "One big test covers everything" | Monolithic tests are fragile and hard to debug | Split into focused, independent tests |
| 合理化理由 | 错误原因 | 必要操作 |
|---|---|---|
| “测试通过了,所以没问题” | 带反模式的测试通过会带来错误信心 | 评估断言质量,而非仅看是否通过 |
| “我们以后再修复测试质量” | 反模式会恶化;不稳定测试每天都会削弱信任 | 现在修复高优先级项,延迟低优先级项 |
| “先跳过这个不稳定测试” | 跳过的测试会成为永久的盲点 | 诊断根本原因,修复或删除 |
| “Mock所有内容更快” | 过度Mock的测试验证的是Mock wiring而非行为 | 仅在架构边界Mock |
| “一个大测试覆盖所有内容” | 单体测试脆弱且难以调试 | 拆分为聚焦、独立的测试 |
${CLAUDE_SKILL_DIR}/references/anti-pattern-catalog.md${CLAUDE_SKILL_DIR}/references/fix-strategies.md${CLAUDE_SKILL_DIR}/references/blind-spot-taxonomy.md${CLAUDE_SKILL_DIR}/references/load-test-scenarios.md${CLAUDE_SKILL_DIR}/references/anti-pattern-catalog.md${CLAUDE_SKILL_DIR}/references/fix-strategies.md${CLAUDE_SKILL_DIR}/references/blind-spot-taxonomy.md${CLAUDE_SKILL_DIR}/references/load-test-scenarios.md