ミューテーションテストは、コードに意図的に小さなバグ(「ミュータント」)を導入し、テストがそれらを検出できるかを確認することで、テストスイートの品質を評価します。実行だけを測定するカバレッジを超えて、テストが実際に欠陥を検出する能力を測定します。
ミューテーションテストの仕組み
1. A tool makes small changes (MUTATIONS) to the code, e.g.:
→ change + to -, > to >=, true to false, remove a statement, change a constant
→ each mutation = a deliberate "bug" (a MUTANT version of the code)
2. Run the TEST SUITE against each mutant:
→ tests FAIL → the mutant is "KILLED" (good — tests caught the bug) ✓
→ tests PASS → the mutant "SURVIVED" (bad — tests DIDN'T catch the bug) ✗
3. MUTATION SCORE = % of mutants killed → measures how good the tests are at catching bugs
