+ Start a Discussion

Basic Explanation: What is Apex Code Coverage, and how to increase it?

Can anyone provide a basic explanation of what Apex Code Coverage is, and how to increase it?
Raghavendra ARaghavendra A
Hi Jess,

Before you move your code from sandbox to production At least 75% of your Apex code must be covered by unit tests, and all of those tests must complete successfully.

Refer the following link to know how to write good unit tests. 


Shivani DesaiShivani Desai
Hi Jess,

Apex code coverage requires that you generate a test record in your test class and test how it behaves under the custom logic in your trigger or apex code.
This test class should atleast touch 75% of your custom code. In other words the more scenarios or records you create for a test class the greater your coverage would be.
You can check your code coverage in developer console. The red part depicts code that has not been covered, blue for covered and white lines for code that does not require coverage.

Hope this helps.