Does anybody know what is the limit for the number of class names for RunSpecifiedTests using SFDX? I assume it will be the same limit as when one deploys a change set either using the salesforce's UI for inbound change sets or using workbench.

Example command:

sfdx force:mdapi:deploy -d src -w 20 -l RunSpecifiedTests -r SomeClass,SomeClass2,SomeClass3 -u myusername@somedomain.com
  • When you say limit, are you referring to the number of test classes you can pass on CLI? – Jayant Das Apr 24 '19 at 12:40
  • @JayantDas yes that's what I mean, let me clarify my question. – Arthlete Apr 24 '19 at 15:07

There are a few places that a limit might come into play for this:

  • A limit from the Salesforce Metadata API - The list specified in the -r flag will become the runTests property of the DeployOptions object passed to the MDAPI. The Metadata API WSDL from my production org places no limit on the size of this property: <xsd:element name="runTests" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
  • A limit on the length of argument that can be passed to the CLI - this seems to be very large. I can't find any documentation of a limit imposed by oclif, the command line framework being used. The underlying node.js/JavaScript limits would seem to be controlling, then. Which is 2^32-1 elements in an array (ie, number of classes you could theoretically pass) and 2^30-25 characters in a string (ie, total characters in the flag's argument).
  • A limit on the total length of the command line that the OS can process. This will be the controlling limit, I believe.
    • On Windows, the cmd.exe command line maxes at 8191 characters. Your sample command above is 91 characters without the list of classes. Which leaves 8100 characters. You could list at least 197 classes in that case ((40 char max classname length + 1 comma) * 197 = 8077)
    • On Windows PowerShell, the max command line length is 32767. So at least 797 class names could be passed.
    • On macOS or Linux, the limits are much larger, in this 2013 Q&A, a user says that the limits are "131072 to 2621440". So you could get a few thousand classnames in there if you wanted to.
|improve this answer|||||
  • Thank you, this is a very thorough answer and probably just what I needed! – Arthlete Apr 25 '19 at 20:07

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.