Back to Glossary
Testing

Test Coverage Threshold

A minimum percentage of code that must be covered by tests, enforced in CI/CD pipelines to ensure new code doesn't decrease overall test coverage.

Definition

Coverage thresholds are configured in testing tools (Jest, Istanbul, pytest-cov) and enforced in CI. Common thresholds: 80% for critical business logic, 60-70% for general code. Types include: line coverage, branch coverage (both if/else paths), and function coverage. Teams can set global thresholds and per-file thresholds for critical code. Coverage gates prevent PRs from merging if they reduce coverage below the threshold.

Why It Matters

Without enforced thresholds, test coverage erodes over time as developers skip tests under deadline pressure. Studies show that codebases with >80% coverage have 50% fewer production bugs. Coverage thresholds are a commitment to quality that becomes part of the development culture.

Example

A project has 85% test coverage with an 80% threshold. A developer submits a PR that adds 200 untested lines, dropping coverage to 78%. CI fails the coverage check, requiring the developer to add tests before merging.

Related Terms

test coverage thresholdcoverage gateminimum coveragecoverage requirementcode coverage percentage

Automate Code Review with diffray

Multi-agent AI system for code review. Automatically finds bugs, security vulnerabilities, and architecture issues.