7

I am creating a tool related test class execution scheduler.

Does Salesforce provide any way for the Tooling API to enable or disable Parallel Test Execution?

I want to set this setting by Apex and run every test classes one by one even after someone has changed the setting manually.

Disable Parallel Apex Testing

2 Answers 2

5

Specifically to your question on "Disable Parallel Apex Testing". No, I don't believe there is currently an official method in the Tooling API that exposes this setting.

That said, with Salesforce DX Scratch orgs we are being told that it will be possible to fully configure the org from a config file. That would imply a way to toggle all these otherwise unexposed settings.

Update: (via @bufuda) The ApexSettings for a scratch org now include a enableDisableParallelApexTesting setting that:

Indicates whether Apex tests are serially executed (true) or not (false). The default value is false.

There is an article from Bob Buzzard on doing a deploy to update the setting after the org has been created. Note that this is via the Metadata rather than Tooling API.


Alternative example of doing this in vscode using a dedicated metadata file.

Path: force-app\main\default\settings\Apex.settings-meta.xml

Metadata file:

<?xml version="1.0" encoding="UTF-8"?>
<ApexSettings xmlns="http://soap.sforce.com/2006/04/metadata">
   <enableDoNotEmailDebugLog>true</enableDoNotEmailDebugLog>
   <enableDisableParallelApexTesting>true</enableDisableParallelApexTesting>
   <enableCompileOnDeploy>false</enableCompileOnDeploy>
</ApexSettings>

Then push this to the org to have the changes reflected.


If you want to go with the unsupported route there you can use the Chrome developer tools to see exactly how that setup page works.

**Request URL:**https://abc.salesforce.com/_ui/common/apex/test/ApexTestQueueServlet
Request Method: POST

Form Data
action: SET_OPTIONS
onlyStoreAggregateCoverage: false
disableParallelApexTesting: true
testAutonumber: false

You could quite easily replicate that POST request (including the sid cookie). If you do so, know that it could break at any point as it isn't an official API.

4
  • 1
    Do we know a GA date for scratch orgs? They're not available yet, right?
    – Adrian Larson
    Commented Jan 11, 2017 at 18:48
  • @AdrianLarson Last I heard they were aiming for GA end of 2017 or early 2018. With a public beta before that. Of course, those dates could all change. Commented Jan 11, 2017 at 19:18
  • Thanks @DanielBallinger for such a great descriptive answer. I raised a case regarding same to salesforce.com support team and they told that this API is not available for now. Commented Jan 12, 2017 at 12:54
  • 1
    This option is now available for scratch orgs in the 'settings' portion of the scratch definition file. Specifically, enableDisableParallelApexTesting: true developer.salesforce.com/docs/atlas.en-us.api_meta.meta/…
    – bafuda
    Commented Nov 6, 2020 at 0:09
5

Perhaps it would help you to look at the Force.com Tooling API documentation, specifically on REST Resources. There are some URIs listed that look useful to you:

  • /runTestsSynchronous/
  • /runTestsAsynchronous/

There is a lot of detail in the documentation around these resources, too much to quote fully here. But they seem to provide an avenue to achieve what you are looking for.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .