---
schema_version: "1"
id: fd2a00058a137130d6324a2fb0b981847b80a22287913c706e59957e3a9f7466
title: Use the Independent Auto-Number Sequence Test Option
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/code_test_execution_idependent_test_option.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.code_test_execution_idependent_test_option.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 3e1d9c6da9197e7c4770f14c836c381c53ac38a752b9887d2cf46846f2bbff0b
description: The Independent Auto-Number Sequence setting helps to avoid gaps in auto-number fields caused by test records created in Apex tests. This option isolates the auto-number sequence used in Apex tests from the sequence used in your org. As a result, the creation of test data in Apex tests doesn’t cause the sequence ofauto-number fields to be higher for new non-test records.
products:
  - Salesforce Platform
release: "264"
---
# Use the Independent Auto-Number Sequence Test Option

The Independent Auto-Number Sequence setting helps to avoid gaps in auto-number fields caused by test records created in Apex tests. This option isolates the auto-number sequence used in Apex tests from the sequence used in your org. As a result, the creation of test data in Apex tests doesn’t cause the sequence ofauto-number fields to be higher for new non-test records.

### 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: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <span id="code_test_execution_idependent_test_option__Apex_Code_editions_text"><a name="code_test_execution_idependent_test_option__Apex_Code_editions_text"></a><strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, <strong>Developer</strong>, and <strong>Database.com</strong> Editions</span></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="d11118e78">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d11118e78 ">
              <span id="code_test_execution_idependent_test_option__class_perm_text"><a name="code_test_execution_idependent_test_option__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="d11118e78 ">
              <span id="code_test_execution_idependent_test_option__apex_perm_value"><a name="code_test_execution_idependent_test_option__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="d11118e78 ">
              <span id="code_test_execution_idependent_test_option__class__runtest_perm_text"><a name="code_test_execution_idependent_test_option__class__runtest_perm_text"><!-- --></a>To run Apex tests:</span>
            </td>

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

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

If this option isn’t enabled, there will be gaps in the auto-number field whenever Apex tests create test records with auto-number fields. For example, if Account has an auto-number field, and there are 50 account records in your organization, the field value of the last created account can be `N-0050`. After running an Apex test that creates five test accounts, this causes the auto-number sequence to be increased by five even though these test records aren’t committed to the database and are rolled back. Next time you create a non-test account record, its auto-number field value will be `N-0056` instead of `N-0051`, hence, the gap in the sequence. If you enable this option before running an Apex test that creates test data, the auto-number sequence is preserved and the next non-test record will have a contiguous auto-number value of `N-0051`.

Gaps in the auto-number sequence can still occur in other situations, for example, when triggers that attempt to insert new records fail to execute and records are rolled back. In this case, gaps can’t be completely avoided because, in the same transaction, some records can be successfully inserted while others are rolled back.

1. Click **Options...**.
2. Select **Independent Auto-Number Sequence**.
3. Click **OK**