I want to know, what can cause a test class to run in a sandbox and PASS all the tests, but on deployment to another sandbox, its failed during the deployment?

all of my data is created in the test class and of course, no hardcoded Ids involved.

I made a test Execution to all of my test classes in my sandbox and it passes in both sandboxes.

Is there a way to have a debug on the test during the deployment on the inbound sandbox?


  • Hi @Salvation, you should update your question to include detail of the test failures and some idea what the test is that is failing so you can get an answer that is more than general.
    – Phil W
    Jul 7, 2019 at 9:37

2 Answers 2


A (partial) list of things that have buggered our tests on deploy (it boils down to: does your deployment include absolutely everything your Apex code needs?):

  • Missing Custom settings referenced in Apex classes
  • Missing Custom labels referenced in Apex classes
  • Apex class permissions not added to a user/profile/permission set
  • Missing fields and/or field level permissions

My problem was that I had a picklist value that was not connected to the recordType in my Inbound Org.

My suggestion for issues like that when this happens (Via sandboxes) is to create your classes in the target Org, run the test classes and debug it there since there no way to debug while deploying the components.

Thanks for the time to those who answered.

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.