Is 80 percent code coverage good? How to set a coverage target

Isometric grid of tiles, most raised and a few flat gaps, showing partial code coverage

TL;DR: Yes, 80 percent code coverage is a reasonable floor for most application code. Google's testing blog calls 60% acceptable, 75% commendable and 90% exemplary (Google Testing Blog, 2020). Coverage only shows which lines ran. It does not show whether the assertions would catch a bug. Set targets by risk, gate new and changed code in each pull request, and use mutation testing to prove your tests can fail. Ship, the ContextQA autonomous quality engineer, runs targeted regressions on each pull request and attaches evidence from each run.

This guide covers line, branch and mutation coverage, how to gate only changed code in a pull request, and how to prove your tests can fail.

Quick answers

Should we enforce an 80 percent coverage gate on the whole repository or only on new code? Gate new and changed code in each pull request. A repo wide gate blocks unrelated work when legacy modules sit below the line. It also lets a well covered old codebase hide an untested new change. A diff coverage check that requires 80 percent of changed lines to run puts the bar on the code under review.

What is the difference between line, branch, and mutation coverage? Line coverage reports which lines executed. Branch coverage reports whether both outcomes of each decision, such as an if, ran. Mutation testing plants small deliberate defects and checks whether a test fails, so it is the only one of the three that measures assertion strength. Check all three on high risk modules.

How can teams tell if developers are gaming the coverage number? Look for tests with no assertions, tests that mock the unit under test, and large coverage jumps in pull requests that change no behavior. Plant a defect on purpose. If coverage stays high and no test fails, the number is inflated. In review, ask what failure each new test would catch.

What does an 80 percent coverage target mean?

An 80 percent coverage target means automated tests must run at least 80% of a codebase's lines or branches. It is a reasonable minimum for most application code, but it does not prove quality: coverage shows which code ran, not whether an assertion checked the result.

80% is a common convention, not a formal industry standard. Google's testing blog calls 60% "acceptable," 75% "commendable" and 90% "exemplary," and says no single number fits every product (Google Testing Blog, "Code Coverage Best Practices," 2020). Atlassian's guide suggests 80% as a good goal for most projects (Atlassian, "What is code coverage?").

For engineering leaders, 80% works as a default for business logic. It is too strict for generated glue code and too loose for payments, authentication or tenant isolation, where one untested branch can turn into a production incident. Treat it as a minimum that triggers review, not a finish line.

What does a coverage number tell you about your tests?

A coverage number shows which code your tests executed, and by subtraction, which code no test touched. It does not show whether any assertion checked the right result. Read coverage as a map of untested code, then use branch and mutation data to judge whether the code that ran was actually verified.

  • Line coverage shows what ran. A line counts as covered once any test executes it, even a test with no assert or expect.
  • Branch coverage shows which decisions ran. It records whether both outcomes of each if, switch case and short circuit condition ran. A function can reach 100 percent line coverage while an implicit else path, such as a bare if with no else body, never runs.
  • Mutation score shows whether tests can fail. Tools such as PIT, Stryker and mutmut inject small defects, such as changing > to >=, and report which of these "mutants" no test caught. Each surviving mutant points to a weak assertion.
  • The gaps show where to look first. Uncovered lines in auth, payments or tenant isolation code matter more than uncovered logging.

For techniques that close those gaps, see the guide to test coverage techniques.

Close-up of HTML code on a dark monitor with syntax highlighting, showing nested div, nav and list elements

Why does the coverage target matter more in 2026?

AI coding assistants now write both application code and its tests. A generated test can run every line and still assert nothing useful, because the implementation and its tests can share the same mistaken assumption. Coverage is cheap to raise and easy to misread, so teams need targets set by risk instead of one repo wide number.

The ContextQA guide to testing AI-generated code recommends writing the behavior contract independently of the implementation, then proving that a deliberate defect makes the relevant assertion fail. A mutation tool automates that same check.

Google's guidance also supports a higher bar for changed code. For individual commits, the Google Testing Blog (2020) calls a 99% goal reasonable and 90% a good lower threshold.

The target also depends on test level. Unit tests carry the line and branch target. Integration tests are judged on critical paths such as persistence, auth and billing. End to end tests are judged by the user journeys they cover, because line coverage from browser runs is noisy and rarely worth gating on.

How do you measure and apply an 80 percent target?

You measure coverage with an instrumentation tool such as coverage.py, JaCoCo or Istanbul (nyc), which records the lines and branches that ran during the suite. Apply 80 percent as a floor on new and changed code in each pull request, tier it by risk, then confirm the tests can fail.

  1. Collect branch data, not just lines. Run pytest --cov=app --cov-branch or turn on JaCoCo branch counters, so an untested else path shows up as a gap.
  2. Gate the diff, not the repo. Run diff-cover coverage.xml --compare-branch=origin/main --fail-under=80 so the check judges only the code in the pull request.
  3. Tier by risk. Set a higher bar for payment, auth and tenant isolation code in coverageThreshold or its equivalent. Generated clients and config wiring can sit lower.
  4. Prove tests can fail. Run PIT or Stryker on critical modules. Surviving mutants expose tests with no assertions or tests that mock the unit under test.
  5. Track outcomes beside coverage. Watch defect escape rate and the change failure rate defined by DORA. If coverage climbs while escapes stay flat, audit your assertions.

Which approach fits your team?

Most teams get the best return from a diff coverage gate. Require about 80% on new and changed lines in each pull request, leave the legacy baseline ungated, and run mutation testing only on high risk modules. A whole repo gate suits small greenfield codebases. Targeted pull request regressions check deployed user journeys, which unit coverage never sees.

ApproachBest forPricing modelNotable tradeoff
Whole repo line gateSmall or new codebasesFree: coverage.py, nyc, JaCoCoBlocks unrelated PRs, invites empty tests
Diff coverage gateLegacy repos climbing from 50%Free: diff-coverIgnores risky code nobody touches
Mutation testingAuth, payments, pricing logicFree: PIT, StrykerSlow, so limit it to critical modules
Ship targeted PR regressionsTeams that need end to end evidence on every merge15 day free trial, then from $49 a month (Ship)Focuses on the behavior of changed flows

To climb from 50% to 80%, gate only changed code with diff-cover. Let AI tools draft tests for uncovered branches in your riskiest files, and reject any generated test that still passes after you plant a deliberate defect.

How does Ship by ContextQA fit next to a coverage gate?

A coverage gate reports which lines ran. Ship checks what that number leaves out: whether the product flows a pull request changed were actually run and verified. It maps each change to affected flows, runs targeted regressions before merge, and returns evidence for review.

That mapping is called impact analysis: tracing a code change to the user flows it can affect (see the ContextQA impact analysis overview). To set it up:

  1. Connect GitHub or GitLab under Integrations. Then open Autonomous SDLC > Code Analysis and confirm the analyzed branch matches the deployed test build (code analysis docs).
  2. Review the generated test candidates. The docs' review checklist asks whether each test verifies "a business result rather than merely finish clicking," which catches tests with no real assertions.
  3. On every pull request, Ship reports the blast radius, the selected tests, the results and the evidence (Ship overview).
  4. Turn confirmed defects into regression tests that run against future changes.
If a coverage number says your tests ran but not whether they can catch a regression, see how Ship by ContextQA runs targeted regressions with evidence on every pull request. Get started free with Ship, no credit card needed.
Black and white photo of a laptop, a smartphone and an open lined notebook with a pen on a dark desk

What should you do now? A checklist

Gate new and changed code at 80% instead of the whole repository, raise the bar for high risk modules, and add checks that prove your tests can fail. You can finish and verify each item in one sprint without changing your release process.

  • Replace any repo wide threshold with a diff gate: diff-cover coverage.xml --compare-branch=origin/main --fail-under=80.
  • When SonarQube reports "Coverage on New Code is less than 80%," write tests for the uncovered changed lines instead of lowering the condition.
  • Give auth, payment and data deletion modules stricter branch targets in coverageThreshold.
  • Run npx stryker run on one high risk module and review the surviving mutants.
  • Turn on the jest/expect-expect lint rule to catch tests with no assertions.
  • Reject tests that mock the unit they claim to test.
  • Each sprint, plant one deliberate defect and confirm that a test fails.
  • Use Ship to run targeted regressions on each pull request and attach the evidence.

Bottom line

80% line coverage is a reasonable floor for most application code, but it only shows which lines ran. Set targets by risk, check branches where the logic is complex, and run mutation testing on critical modules. Gate changed code in each pull request and reject tests without assertions. For more, see the test coverage techniques guide linked above and the test automation webinar.

Sources

Every coverage threshold quoted here links to the guidance that published it. The ContextQA documentation pages describe the Ship workflow steps above. No benchmarks or customer results are cited.

Share the Post:

Author

Deep Barot

CEO @ ContextQA | Agentic AI for Software Testing | Context-aware Testing

Deep Barot is the Founder and CEO of ContextQA, the only AI testing platform that understands context. He brings decades of experience across DevOps, full-stack engineering, cloud systems, and large-scale platform development.
AI Insights
Real User Intelligence Platform

Turn live sessions into test coverage. No prompts, no manual design - just pointed at your URL and generating suites within minutes.

Minutes
From URL to generated test cases
Zero
Prompts or manual test design needed
40%+
Average coverage increase after first run
100%
Based on real user behavior, not guesses

Frequently Asked Questions

Eighty percent is a reasonable floor for most enterprise code. Raise it only where the risk justifies it. Hold payment, authorization and data integrity paths to stricter branch and mutation targets, gate new and changed code in each pull request, and accept lower coverage on generated or glue code.
High coverage means fewer bugs only when the tests check the right outcomes. Coverage shows which lines ran, not whether a wrong result would fail the build. A suite with high coverage can still miss a tenant isolation bug, an off by one expiry or an unhandled error path if no assertion checks for it.
Rank each module by what a defect would cost and how likely one is. Payment, auth, tenant isolation and data migration code needs branch coverage above 80 percent, plus mutation testing to show the assertions catch defects. Code that changes often or has a history of incidents also moves up the list. Glue code and generated code can sit below the 80 percent floor.
Related Blogs