Business

Understanding Code Coverage in Salesforce

By March 23, 2018 No Comments

A lot of clients have asked us what Code Coverage is in Salesforce. Here's a simple way to help explain how to use and check code coverage for SF admins.

When using custom codes in Salesforce.

Everytime you use custom code in Salesforce (a "class" or "controller") to tell it to perform or achieve some sort of functional objective, you need to pair it with a testing class ("test class"). These test classes are given a percentage score of how robust they are - the more scenarios tested, the closer to 100% they get. The purpose is to see how your custom APEX code will behave "in the wild."

Each test class should at least reach 75% of coverage.

If below 75%, you cannot deploy code from the Sandbox to Production until the overall code coverage is bolstered.

You can perform validations (mock deployments) to see which tests are either failing or below 75%.

You can also can check your code coverage in your developer console as an Admin.