跳到正文
Skillpedia
测试75k · #2945

mutation-testing

它能做什么

这项技能设置并检查变异测试,这种方法会对代码做小改动,看测试是否会失败。适用于希望了解测试是否足以覆盖关键逻辑的开发者。

适用场景

  • ✓当你请智能体检查测试能否捕捉真实错误的时候。
  • ✓当覆盖率数字很高,但你怀疑测试并没有检查有意义的结果的时候。
  • ✓当你想把测试改进集中在一个重要的业务逻辑模块上的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/mutation-testing/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/mutation-testing/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2945
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能