5

I love to run my tests in the Dev Console with the Always Run Asynchronously checkbox enabled as it saves time.

enter image description here

On the other side during our automated Nightly Test run I would like to disable Parallel test runs as we otherwise have to many false positives with UNABLE_TO_LOCK_ROW errors.

enter image description here

It seems I can't do both. As the screenshot indicates tests in the Dev Console run sequentially even with the async checkbox on.

  • Just curious, why do you care how quickly the nightly test suite runs? – Adrian Larson Sep 23 '16 at 10:12
  • 2
    Also, I don't see how your screenshot demonstrates that tests are run in parallel when you don't want them to be? – Adrian Larson Sep 23 '16 at 10:13
  • Agree with @AdrianLarson Whenever I check the checkbox it works as expected. – Tushar Sharma Sep 23 '16 at 10:15
  • @AdrianLarson I don't care about the speed of my nightly test. That's why I want them to run sequentially. Otherwise (if they run fast and in parallel) some will fail with UNABEL TO LOCK ROW. – Robert Sösemann Sep 23 '16 at 10:35
  • 2
    As per the screenshot, parallel run is disabled. And Async run is on. Did 'Disable Parallel Apex Testing' de-select itself when 'Always Run Asynchronously' checked? Otherwise behavior seems obvious as parallel run is off. – Ashwani Sep 23 '16 at 12:43
6

I believe you're getting confused. Asynchronously has nothing to with parallelism. For the first box (Disable Parallel Testing), when checked, tests run one after another, and when unchecked, run several classes at a time.

The second box (Always Run Asynchronously) tells the Developer Console if it should run tests in the background or not. When checked, the test appears in the test panel and will be updated periodically as the test completes. When not checked, the "Run Test Synchronously" dialog will appear, blocking the IDE entirely until the test runs. You can observe the difference in behavior by running a test that is several seconds long with the box checked or not to see the difference.

As far as I know, there's no API to set if tests run in parallel or not, simply the Disable Parallel Testing checkbox in the UI. It is also explicitly overridden when running tests during deployment to production to avoid the UNABLE_TO_LOCK_ROW errors you've mentioned. The Developer Console will honor the Disable Parallel Testing checkbox regardless of the "Always Run Asynchronously" checkbox.

1

First, let me clear that the two things - Disable Parallel Testing and Always Run Asynchronously are completely different. Here is each one's explanation in my words,

Disable Parallel Testing checkbox if checked, mandates the platform to run each test class one after the other. So, we can say that this setting is test class specific. If checkbox is unchecked, the platform will run the test classes in parallel.

Always Run Asynchronously checkbox if checked, mandates the platform to run test methods in a single test class to run in parallel. If unchecked, the test methods will run one after the other.

Note there is no dependency of the earlier setting with the later setting.

Hope this helps.

Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.