Apex test levels, coverage and test execution
Which Apex tests each deployment test level runs, how the 75% coverage rule is calculated and why sandbox and production figures differ, and how to run, schedule and inspect tests with the CLI, the test queue and the Tooling API coverage objects.
Given a customer testing strategy, describe the appropriate test execution methodology and coverage requirements.
~8 min read · 13 practice questions ·
What the exam expects
- Choose the deployment test level for a sandbox or production deployment, and say which tests each level runs and which coverage check applies.
- Calculate overall coverage after a release, and apply the 75% and every-trigger rules.
- Explain why coverage differs between a sandbox and production, or drops in production over time, and recommend the fix.
- Run and schedule tests at scale: CLI test suites and result formats, the daily test-class limit, Store Only Aggregate Code Coverage, and per-method coverage in the Tooling API.
- Explain why tests stay in the org after go-live and why production deployments never ignore errors.
Key terms: test level (which tests a deployment runs), overall coverage (covered lines divided by all executable Apex lines in the org), per-class coverage (the 75% each deployed class and trigger needs under RunSpecifiedTests), ApexCodeCoverage (Tooling API object with covered and uncovered lines per test method), test suite (a named set of test classes run together).
Key facts
- Detail
- NoTestRun
- Detail
- RunLocalTests
- Detail
- 75% for each deployed class and trigger, computed individually, not overall
- Detail
- Beta; tests chosen from payload analysis; 75% per class and trigger
- Detail
- At least 75% overall; every trigger some coverage
- Detail
- Test classes, lone
System.debug()lines, comments
- Detail
- Not refreshed until tests rerun
- Detail
- Synchronous and serial; UI runs are parallel
- Detail
- Greater of 500 or 10x classes; sandbox 20x
- Detail
- ApexCodeCoverage (Tooling API)
--ignore-errors- Detail
- Never against production
Sources for this section (6)
- project deploy startdeveloper.salesforce.com (opens in a new tab)
- deploy()developer.salesforce.com (opens in a new tab)
- Testing in Apexdeveloper.salesforce.com (opens in a new tab)
- Testing and Code Coveragedeveloper.salesforce.com (opens in a new tab)
- Coverage Best Practicesdeveloper.salesforce.com (opens in a new tab)
- Run Unit Test Methodsdeveloper.salesforce.com (opens in a new tab)
- Why can production coverage drop below 75% months after a successful deployment?
- When do Apex tests run serially rather than in parallel?
- Which test level runs managed package tests?
- Why keep passing tests in production after go-live?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the Platform Development Lifecycle and Deployment Architect pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 26 lessons of the Platform Development Lifecycle and Deployment Architect guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Inline practice questions and one-click topic practice (13 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams