7

We're running a CI process with the Force.com Migration tool and using <sf:deploy checkOnly="true" testLevel="RunLocalTests" ...>

The build times are climbing up there as we add more tests. Is there any way to enable parallel test execution? It seems like the metadata deploy is always serial. Would it require a deploy, test with tooling, undeploy?

Edit: Found this in the Force.com migration tool doc pg. 19 (https://resources.docs.salesforce.com/206/latest/en-us/sfdc/pdf/salesforce_migration_guide.pdf)

"Apex tests that run as part of a deployment always run synchronously and serially."

So it looks like it would be a deploy, run tests, undeploy org approach. Then I'm curious if anyone has done a successful undeploy.

1 Answer 1

13

Tests always run in serial during deployments; this helps avoid spurious errors because of CANNOT_LOCK_ROW errors. This is true for the migration tool, package installs (when applicable), and change sets. If you're concerned about running tests for CI, then yes, it would make more sense to deploy, run tests, then undeploy. Salesforce DX will probably make this chore less tedious for CI systems.

7
  • what do you mean "undeploy"?
    – rzr
    Aug 8, 2019 at 21:37
  • @rzr Essentially, "revert the system to the previous state." For non-unlocked packages, this means a destructiveChanges.xml and/or the old metadata prior to the initial deployment. Some systems, like Gearset, make this pretty easy to accomplish via metadata backups. If using unlocked packages, we are allowed to install a previous version, which acts like an undeploy.
    – sfdcfox
    Aug 8, 2019 at 21:42
  • @sfdcfox Can tests run in parallel via ant if we add isParallel=true on each test class or test method. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… Oct 17, 2019 at 6:10
  • @NagendraSingh Only if you're not deploying. Deployments still process tests one at a time. If you just choose to run tests without a deployment, parallelism may be used to quickly identify test failures.
    – sfdcfox
    Oct 17, 2019 at 14:11
  • @sfdcfox By not deploying you mean checkOnly as true, so if build.xml has checkOnly as true, the isParallel=true will make the tests run in parallel via ant migration tool. Right? Oct 18, 2019 at 3:48

You must log in to answer this question.

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