Loading

Apex Code Coverage: Avoid Meaningless Test Statements to Inflate Coverage Ratio

Publiceringsdatum: Oct 5, 2026
Beskrivning

Apex code coverage measures the percentage of your org's Apex code that is executed by test methods. This article explains why intentionally inflating that percentage with meaningless statements is discouraged, and what Salesforce may require if it's found in your org.

Lösning

Why Meaningless Test Statements Are a Problem

In Apex code development, we don't recommend increasing your org's code coverage ratio by intentionally creating Apex classes or methods containing meaningless, redundant statements — for example, unnecessary variable assignments or repeated calculations that aren't actually used by your application.

If code deployed to production skips a test that should have been run, these meaningless statements can cause unintended behavior or issues. They also skew the true upper limit of Apex characters used in your org, since the code technically counts toward your character limit without providing real test value.

What Salesforce May Ask For

When Salesforce reviews your org's Apex character upper limit, we look at the details behind that number. If meaningless statements are found inflating your code coverage, Salesforce may ask you to modify the Apex code to remove them.

Knowledge-artikelnummer

000382195

 
Laddar
Salesforce Help | Article