---
schema_version: "1"
id: b97e654992c33dd322c5b25e4c902ade2eba1aa8ac51ba20b8a9936dd83ccb66
title: Application Unit Tests
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/code_run_tests.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.code_run_tests.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 4c8abf9b2a2e203b8da829ca0bf6d3dbb8865752f397d9a2abb34f7c709f3644
description: Run Apex and automated flow unit tests on methods, classes, sets of classes, or your whole org.
products:
  - Salesforce Platform
release: "264"
---
# Application Unit Tests

Run Apex and automated flow unit tests on methods, classes, sets of classes, or your whole org.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition">
      <colgroup>
        <col>
      </colgroup>
      <tbody>
        <tr class="">
          <td class="slds-cell-wrap" style="vertical-align:top;">Available in: Salesforce Classic (<a href="https://help.salesforce.com/s/articleView?id=xcloud.overview_edition_lex_only.htm&amp;language=en_US" target="_blank">not available in all orgs</a>) and Lightning
            Experience</td>

        </tr>
        <tr class="">
          <td class="slds-cell-wrap" style="vertical-align:top;">
            <p>Available in: <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>,
              <strong>Developer</strong>, and <strong>Database.com</strong> Editions
            </p>
            <p>Managed Packages are not
              available in <strong>Database.com</strong>.</p>
            <p style="margin-bottom:0;">See <a href="https://help.salesforce.com/s/articleView?id=platform.flow_ref_supported_editions.htm&amp;type=5&amp;language=en_US" target="_blank">Supported Editions for Flow Builder and Licenses
                for Integrated Features</a></p>
          </td>

        </tr>
      </tbody>
    </table> <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
      <colgroup>
        <col style="width:74%">
        <col style="width:26%">
      </colgroup>
      <thead class="slds-text-title_caps ">
        <tr class="">
          <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d23820e88">User Permissions
            Needed</th>
        </tr>
      </thead>
      <tbody>
        <tr class="">
          <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d23820e88 ">
            <span id="code_run_tests__class_perm_text"><a name="code_run_tests__class_perm_text"><!-- --></a>To define, edit, delete, set security, and set version
              settings for Apex classes:</span>
          </td>

          <td class="slds-cell-wrap" style="vertical-align:top;" headers="d23820e88 ">
            <span id="code_run_tests__apex_perm_value"><a name="code_run_tests__apex_perm_value"><!-- --></a>Author Apex</span>
          </td>

        </tr>
        <tr class="">
          <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d23820e88 ">
            <span id="code_run_tests__class__runtest_perm_text"><a name="code_run_tests__class__runtest_perm_text"><!-- --></a>To run Apex tests:</span>
          </td>

          <td class="slds-cell-wrap" style="vertical-align:top;" headers="d23820e88 ">
            <span id="code_run_tests__apex_runtest_perm_value"><a name="code_run_tests__apex_runtest_perm_value"><!-- --></a>View Setup and Configuration</span>
          </td>

        </tr>
        <tr class="">
          <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d23820e88 ">To open, edit, or create a flow test in Flow Builder:</td>

          <td class="slds-cell-wrap" style="vertical-align:top;" headers="d23820e88 ">Manage Flow</td>

        </tr>
        <tr class="">
          <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d23820e88 ">To view test run details in Flow Builder:</td>

          <td class="slds-cell-wrap" style="vertical-align:top;" headers="d23820e88 ">View All Data</td>

        </tr>
      </tbody>
    </table>

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_code-264-0-0-production-enus/789bc523-706b-4ae4-8fe9-be6322e38b6b/images/icon_note.png)

Note Only flow tests created with [automated flow testing](https://help.salesforce.com/s/articleView?id=platform.automate_flow_test_record_data_cloud_triggered.htm&type=5&language=en_US) in Flow Builder are supported.

You can run these groupings of Apex and flow unit tests.

- Some or all methods in a specific class
- Some or all methods in a set of classes
- A predefined suite of classes, known as a test suite
- All unit tests in your org

Apex tests that are started from the Salesforce user interface run in parallel. Unless your test run includes only one class, and you didn’t select **Always Run Asynchronously** from the Developer Console’s Test menu, test runs started from the user interface are asynchronous. Apex test classes are placed in the Apex job queue for execution. The maximum number of test classes you can run per 24-hour period is the greater of 500 or 10 multiplied by the number of test classes in the org. For sandbox and Developer Edition organizations, this limit is the greater of 500 or 20 multiplied by the number of test classes in the org.

## Code Coverage by Unit Tests

Before you can deploy your code or package it for the Salesforce AppExchange, the following must be true:

- Unit tests must cover at least 75% of your Apex code, and all of those tests must complete successfully.
    - When deploying Apex to a production organization, each unit test in your organization namespace is executed by default.
    - Calls to `System.debug` are not counted as part of Apex code coverage.
    - Test methods and test classes are not counted as part of Apex code coverage.
    - While only 75% of your Apex code must be covered by tests, don’t focus on the percentage of code that is covered. Instead, make sure that every use case of your application is covered, including positive and negative cases, as well as bulk and single records. This approach ensures that 75% or more of your code is covered by unit tests.
- Every trigger must have some test coverage.
- All classes and triggers must compile successfully.

If your test calls another class or causes a trigger to execute, that class or trigger is included in the code coverage calculations.

After tests are executed, code coverage results are available in the Developer Console.

To generate code coverage results, first run your tests using one of the following methods.

- To run all tests from the Developer Console, select **Test** | **Run All**. Running a subset of tests doesn’t always update code coverage results properly, so running all your tests is the best way to see your code coverage.
- To select and run tests from the Developer Console, see [Create a Test Run](https://help.salesforce.com/s/articleView?id=platform.code_dev_console_test_runs_creating.htm&release=264.0.0&type=5 "A test run is a collection of classes that contain test methods. Set up a test run in the Developer Console to execute the test methods in one or more test classes.").
- To set up a reusable test suite from the Developer Console, see [Manage Sets of Apex Test Classes with Test Suites](https://help.salesforce.com/s/articleView?id=platform.code_dev_console_test_suites_creating.htm&release=264.0.0&type=5 "A test suite is a collection of Apex test classes that you run together. For example, create a suite of tests that you run every time you prepare for a deployment or Salesforce releases a new version. Set up a test suite in the Developer Console to define a set of test classes that you execute together regularly.").
- To run all Apex tests from Setup, enter Apex in the Quick Find box, select **Apex Classes**, then click **Run All Tests**.
- To run tests for an individual class from Setup, enter Application in the Quick Find box, then select **Application Test Execution**. Click **Select Tests**, select the classes containing the tests you want to run, and then click **Run**.

After running tests, you can view code coverage results in the Developer Console. These results include the lines of code that are covered by tests for an individual class or trigger. See [Checking Code Coverage.](https://help.salesforce.com/s/articleView?id=platform.code_dev_console_tests_coverage.htm&release=264.0.0&type=5 "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).")

#### See Also

- [Execute Application Tests](https://help.salesforce.com/s/articleView?id=platform.code_test_execution.htm&release=264.0.0&type=5 "Select the Apex and flow tests that you want to run. Then examine the results, analyze error messages, and inspect your Apex source code.")
- [_Apex Developer Guide_: Code Coverage Best Practices](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_code_coverage_best_pract.htm)
- [Automatically Test Record-Triggered and Data Cloud-Triggered Flows](https://help.salesforce.com/s/articleView?id=platform.automate_flow_test_record_data_cloud_triggered.htm&type=5&language=en_US)
- [_Tooling API Reference Guide_: REST Resources for Unit Testing](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_rest_resources_testing.htm)