Tests that are started from the Salesforce user interface (including the Developer
Console) run in parallel. Parallel test execution can speed up test run time. Sometimes, parallel
test execution results in data contention issues, and you can turn off parallel execution in those
cases.
Required Editions
Available in: Lightning Experience
Available in: Enterprise, Performance,
Unlimited, Developer, and Database.com Editions
To define, edit, delete, set security, and set version settings for
Apex classes:
Author Apex
To run Apex tests:
View Setup and Configuration
To open, edit, or create a flow test in Flow Builder:
Manage Flow
To view test run details in Flow Builder:
View All Data
In particular, data contention issues and UNABLE_TO_LOCK_ROW errors can occur
in these cases.
When tests update the same records at the same time—Updating the same records typically
occurs when tests don’t create their own data and turn off data isolation to access the org’s
data.
When a deadlock occurs in tests that are running in parallel and that try to create records
with duplicate index field values—Test data is rolled back when a test method finishes
execution. A deadlock occurs when two running tests are waiting for each other to roll back
data, which happens if two tests insert records with the same unique index field values in
different orders.
You can prevent receiving those errors by turning off parallel test execution in the
Salesforce user interface.
From Setup, enter Application in the Quick Find box, select
Application Test Execution, then click
Options....
In the Application Test Execution Options dialog, select Disable Parallel Apex
Testing and then click OK.
For more information about test data, see Isolation of Test Data from Organization Data
in Unit Tests in the Apex Code Developer Guide. This option doesn’t affect the execution
order of tests, which continue to run asynchronously from the Application Test Execution
page.
Did this article solve your issue?
Let us know so we can improve!
Loading
Salesforce Help | Article
Cookie Consent Manager
General Information
Required Cookies
Functional Cookies
Advertising Cookies
General Information
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required Cookies
Always Active
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional Cookies
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising Cookies
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.