Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Code Coverage entry
How-to guide

How to maintain meaningful Code Coverage

Hitting 75 percent coverage is the floor; treating it as a target is the start of test debt. Mature teams aim higher and pair coverage with assertion-quality reviews.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated May 20, 2026

Hitting 75 percent coverage is the floor; treating it as a target is the start of test debt. Mature teams aim higher and pair coverage with assertion-quality reviews.

  1. Write test methods alongside production code

    Every new class or trigger gets a corresponding test class. Treat tests as part of the implementation, not an afterthought.

  2. Use meaningful assertions

    System.assertEquals, System.assertNotEquals, System.assert with explicit expected values. Tests without assertions raise coverage without raising quality.

  3. Run tests in CI on every change

    Configure CI/CD to run Apex tests on every pull request. Block merges that drop coverage below the team's target (usually 85 to 95 percent).

  4. Monitor coverage over time

    Query ApexCodeCoverageAggregate weekly. Build a dashboard showing trend; declining coverage is a signal to address before the production deploy gate enforces it.

  5. Investigate uncovered code paths

    The Code Coverage page highlights uncovered lines. Investigate them; if production code is genuinely unreachable, simplify; if it is reachable, write the missing test.

Gotchas
  • 75 percent is a floor, not a target. Tests at 75 percent without assertions provide no real quality assurance.
  • Coverage that drops slowly is invisible until the deploy gate fails. Monitor trend, not just point-in-time numbers.
  • Managed package classes have their own coverage; subscribers cannot improve it.
  • Tests that only exercise code without asserting outcomes inflate coverage without preventing defects. Pair coverage with assertion reviews.

See the full Code Coverage entry

Code Coverage includes the definition, worked example, deep dive, related terms, and a quiz.