Does SF run the tests in order in which the tests are specified in
while running tests in a Deployment?



TestClass1 runs before TestClass2, and so on.


  • Out of curiosity, why do you ask?
    – sfdcfox
    Apr 15, 2021 at 3:36
  • Same . Curiosity. I was trying for a validation run today , there were interdependent classes and this doubt occurred to me. Apr 15, 2021 at 10:08

1 Answer 1


Shorter answer: apparently, yes.

Longer answer: Several casual attempts to get the tests to run out of order did not work, so it appears to be that the tests will run in the order you specify. However, without any formal documentation, there is no way to confirm that this will always be true for all possible configurations, and you should not rely on this behavior for the purposes of avoiding row lock errors or other edge cases in your unit tests.

Edit: If anyone has more definitive proof either way, please feel free to leave a comment or edit this answer.

  • AFAIK it goes alphabetically. I was working in a legacy project where test class used to take 2-4 hrs. so we used to do the trick by changing name with a_ to have it first and we can get errors faster.
    – Ysr Shk
    Apr 15, 2021 at 5:29
  • in posted question, if you try to see TestClass2 first, I don't think it'll be executed first. However I leave it upto OP
    – Ysr Shk
    Apr 15, 2021 at 5:30
  • @YsrShk If you RunLocalTests, it appears to be in either CreatedBy or LastModified order (not sure, I don't modify classes much?), but if you specify RunSpecifiedTests, it appears to be in specified order. Give it a try and see if you can replicate it.
    – sfdcfox
    Apr 15, 2021 at 5:44
  • Will try the a_ approach and RunSpecifiedTests one. Apr 15, 2021 at 10:11

You must log in to answer this question.

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