Enter your Apex class names, total lines, and tested lines. The calculator instantly shows individual and aggregate coverage — and tells you if you'll pass Salesforce's 75% deployment requirement.
Before you can deploy Apex code to a production org, Salesforce requires that at least 75% of your Apex code is covered by unit tests. This is measured at the org level — the aggregate of all Apex classes and triggers — not per individual class.
However, best practice is to aim for 90%+ per class, leaving headroom so that new untested code doesn't accidentally drop you below the threshold during deployment.
In Salesforce, a line is "covered" if at least one test method executes it. Lines that count include executable statements, method calls, assignments, conditions in if/else branches, and DML operations. Lines that don't count include comment lines, blank lines, class/method declarations, curly braces alone, and lines containing only variable declarations.
To see exact coverage, run your tests in Developer Console (Tests → Run All) or via Apex Test Execution in Setup. The Coverage tab shows per-class line-by-line coverage.
Cover both positive and negative paths. Most developers write tests for the happy path only. Exceptions, null values, and governor limit edge cases are where real bugs live — and covering them counts toward your percentage.
Use @isTest(SeeAllData=false) (the default). Always create your own test data rather than relying on org data — it makes tests more reliable and faster.
Test bulk operations. Triggers must handle 200 records at once (the DML batch size). A test with a single record may pass coverage but miss governor limit bugs.
Use Test.startTest() / Test.stopTest() around your action code. This resets governor limits for the test operation and ensures async code runs synchronously.
Don't write junk tests. Tests that call methods without asserting anything count toward coverage but provide zero quality signal. Always System.assert(), System.assertEquals(), or System.assertNotEquals().
No — Salesforce measures aggregate coverage across all Apex classes and triggers in your org. Individual classes can be below 75% as long as the org-wide total meets the threshold. That said, aim for 90%+ per class as a best practice.
No. Classes annotated with @isTest are excluded from the coverage calculation entirely — both from the "total lines" count and from the "tested lines" count.
Your deployment fails. Salesforce returns a deployment error indicating insufficient test coverage. Sandboxes don't enforce the 75% requirement, which is why it often catches developers off-guard.
Not exactly. Coverage is measured when tests run during the deployment process. Coverage is always recalculated at deployment time using your production-deployed test classes.
We can audit your org's test suite and write the missing coverage — typically turning a 60% org into a 90%+ org in a single sprint.
Talk to us →