Loading
Enhance Salesforce with Code
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Checking Code Coverage

          Checking Code Coverage

          The Developer Console retrieves and displays code coverage information from your organization. Code coverage results come from any tests you’ve run from an API or from a user interface (for example, the Developer Console, the Salesforce Extensions for Visual Studio Code, or the Application Test Execution page).

          To clear the current results, click Test | Clear Test Data. When you edit a class, the code coverage for that class is cleared until you run the tests again.

          You can view code coverage in several places in the Developer Console.

          • The Tests tab includes an Overall Code Coverage panel that displays the code coverage percentage for every Apex class in your organization that has been included in a test run. It also displays the overall percentage.
          • Double-click a completed test run to open a Tests Results view that displays the tested class, the tested method, the duration, result (skip, pass, or fail), and an optional error message. If the test failed, a Stack Trace column shows the method and line number at which the test failed.
          • To view line-by-line code coverage for an Apex class, open the class. The Code Coverage menu will include one or more of the following options depending on the tests you have implemented:
            • None
            • All Tests: The percentage of code coverage from all test runs.
            • className.methodName: The percentage of code coverage from a method executed during a test run.

            Lines of code that are covered by tests are blue. Lines of code that aren’t covered are red. Lines of code that don’t require coverage (for example, curly brackets, comments, and System.debug calls) are left white.

            Code coverage in the Developer Console
          Note
          Note When you edit a class with code coverage, the blue and red highlighting in the Source Code Editor dims to indicate that the coverage is no longer valid. When you edit and save a class, the coverage is removed for that class. To check coverage for that class, run the tests again.
           
          Loading
          Salesforce Help | Article