Problem Statement
What does code coverage measure?
Explanation
Code coverage measures percentage of code executed during test runs. Coverage types: line coverage (lines executed), branch coverage (if/else branches taken), function coverage (functions called), statement coverage (statements executed). Tools: JaCoCo (Java), Istanbul/nyc (JavaScript), Coverage.py (Python), SimpleCov (Ruby).
Coverage reports show: total coverage percentage, uncovered lines/branches, coverage per file/package. Example: 85% line coverage means 85% of code lines executed by tests, 15% untested. Coverage identifies untested code requiring more tests. However, high coverage doesn't guarantee good tests - tests must assert correct behavior.
CI/CD integration: generate coverage reports, enforce minimum thresholds (e.g., 80%), fail build if coverage drops, display coverage trends. Example: Codecov, Coveralls integrate with GitHub showing coverage changes in pull requests. Coverage helps but shouldn't be sole quality metric. Understanding code coverage enables measuring test completeness.
