mutation-testing
它能做什么
这项技能设置并检查变异测试,这种方法会对代码做小改动,看测试是否会失败。适用于希望了解测试是否足以覆盖关键逻辑的开发者。
适用场景
- ✓当你请智能体检查测试能否捕捉真实错误的时候。
- ✓当覆盖率数字很高,但你怀疑测试并没有检查有意义的结果的时候。
- ✓当你想把测试改进集中在一个重要的业务逻辑模块上的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/mutation-testing/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的代码测试覆盖率很高,但我不确定测试能否发现真正的错误。请帮我设置变异测试?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会为一个模块配置 Stryker,运行它注入小改动,并列出测试未能发现的改动。然后它会改进测试,使这些改动能够被捕捉。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use mutation testing to measure how well tests detect bugs
A codebase can have 90% line coverage and still ship critical bugs if tests only execute code without asserting meaningful outcomes. Mutation testing reveals these gaps by proving that your tests can distinguish correct code from subtly broken code — the standard that actually matters in production.
Quick Reference
- Code coverage tells you which lines were executed; mutation score tells you which bugs were caught
- Stryker injects small code changes (mutations) and checks whether tests fail — if they don't, the tests are weak
- Aim for 80%+ mutation score on critical business logic paths
- Run Stryker on a focused scope (one module) rather than the whole codebase to keep CI times manageable
Check
Assess whether this module has mutation testing configured and whether the mutation score on critical paths meets the project's quality threshold.
Fix
Set up Stryker for this module, run an initial mutation report, and improve tests to kill surviving mutants in the critical business logic paths.
Explain
Explain what mutation testing is, how Stryker works, and why mutation score is a more meaningful quality signal than code coverage alone.
Code Review
Review the Stryker configuration and mutation report to identify surviving mutants in critical code paths, and suggest test improvements to kill them.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/testing/mutation-testing
常见问题
变异得分和覆盖率有什么区别?
覆盖率显示哪些代码行被执行过,而变异得分显示测试实际发现了哪些错误。
为什么一次只测一个模块?
这项技能建议聚焦范围,以便让 CI 运行时间保持可控。
应该争取多少分?
这项技能建议在关键业务逻辑路径上争取达到 80% 或以上。
详情
作者的原始描述
Use when evaluating test quality on modules containing business logic, calculation utilities, or state machines to determine whether the tests provide genuine defect detection.
热度
- GitHub 星标
- 75k
- 排名
- #2945
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。