テストカバレッジは、テストによって実行されるコードの量を測定します。通常はパーセンテージで表現されます(例:80%のカバレッジ)。テストされていないコードを見つけるのに便利なメトリクスですが、その制限を理解することが重要です。高いカバレッジは、必ずしも良いテストを保証するわけではありません。
カバレッジが測定するもの
TEST COVERAGE = the % of code exercised by the test suite:
LINE coverage → % of code lines executed by tests
BRANCH coverage → % of branches (if/else paths) taken
FUNCTION coverage → % of functions called
STATEMENT coverage → % of statements executed
→ Coverage tools instrument the code and report what tests do/don't exercise.
カバレッジが有用な理由
✓ FINDS UNTESTED code — low coverage areas reveal what lacks tests (a gap finder)
✓ A measurable quality signal; track it over time; many teams set a target (e.g. ≥80%)
✓ Highlights branches/paths/error cases that tests miss
