[SalesForce] Test Class is sucssess in Sandbox but failed on deployment

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?

Thanks!

Best Answer

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
Related Topic