Code Coverage とは?
code coverage は、テストスイートの実行時にソースコードのどれだけが実行されるかを報告するメトリクスで、一般に line、branch、function がカバーされた割合として表されます。それはコードベースの未テスト領域を浮き彫りにします。高い coverage はテストがコードに到達していることを示しますが、正しい挙動を assert しているとは限りません。
なぜ重要か
coverage は、どのコードにテストがまったくないかの有用な地図であり、CI で追跡しやすいものです。しかしそれは下限であって上限ではありません。弱い assertion での 100% coverage でもバグを見逃します。品質の保証としてではなく、ギャップへのガイドとして扱いましょう。
関連する概念
- line、branch、function coverage は異なる
- mutation testing は coverage が見逃す assertion の強さを測定する
- しばしば CI の status check の閾値として強制される
関連ガイド
What Is Mutation Testing?Mutation testing measures test-suite quality by deliberately introducing bugs and checking whether the tests…
What Is a Regression Test?A regression test verifies that previously working functionality still works after a change, catching newly i…
What Is a Status Check?A status check is a pass/fail signal a pipeline reports back to a commit or pull request, often required befo…