2

I am getting the below issue, while performing Run All test in my Org. we have a good amount of batch classes,around 15, and we wrote the test classes for them where we are calling the batch Database.execute to cover the batch class. we have put all execute call between Test.startTest and Test.stopTest

Failure Message: "System.LimitException: Attempted to schedule too many concurrent batch jobs in this org (limit is 5)."

Please suggest the solution..

2

Have you tried to disable parallen apex testing, as you're already making use of Test.startTest and Test.StopTest this should prevent test methods to run at the same time.

Setup > Develop > Apex Test Execution > options (button on the top) ---> chek the Disable Parallel Apex Testing chekbox

  • Thanks I will try this approach and let you know the Outcome. Just wonder what will happen when I deploy the code. In deployment, all the test classes will run for sure.Can we disable the parallel apex testing in that case also . – amidstCloud Jun 3 '13 at 13:29
  • I believe those options impact all testing (on the specific org in which you set them), irrelevant of the interface through which your tests get launched (ide, the page, dev console, deploy, ..) – Samuel De Rycke Jun 3 '13 at 13:39
  • This also solves the locking error when we run a bunch of test classes at once? – doga Aug 23 '13 at 7:47
  • @doga Yes it does :-) – Samuel De Rycke Aug 23 '13 at 8:01
0

By default now Salesforce runs tests at the same time. So the combination of several tests might be pushing you over the limit. You can disable this behaviour in setup | develop | apex Test Execution then click on the Options button.

enter image description here

Edit--
You can read more about this in the Spring release notes, page 111 https://na10.salesforce.com/help/doc/en/salesforce_spring13_release_notes.pdf. Note "Tests that are run as part of a deployment, a package install, or a package upload still run synchronously."

  • Just wonder what will happen when I deploy the code. In deployment, all the test classes will run for sure.Can we disable the parallel apex testing in that case als – amidstCloud Jun 3 '13 at 13:43
  • You will be fine. Tests that are run as part of a deployment, a package install, or a package upload still run synchronously – Doug B Jun 3 '13 at 13:47
0

If you are running into this limit in a non test context there is no such easy cure. You basically have to build you own Apex queue. Which I did ;) and as part of a GitHub project I would love to get your feedback and invite you to fork and collaborate on it.

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.