[SalesForce] Unable to deploy code to Sandbox as installed Managed Package test methods are failing

I am using ant tool to deploy code to Sandbox which has Managed package test methods failures. Build error shows the validation rule message. Build is executed by Jenkins schedule job, so turning on and off the validation rule is not possible eachtime. Build.xml files has with "runalltests=true".

Following things I came to understand from the Force.com Migration Tool guide:

  1. While deploying the code to Production all tests except of Managed Package will be executed regardless of the "runalltests" value, is this not the case with Sandbox?
  2. In some of the stackexchange question I saw <runtest namespace="default" /> But document don't have anything related to this

Best Answer

While deploying the code to Production all tests except of Managed Package will be executed regardless of the "runalltests" value, is this not the case with Sandbox?

That is not correct. All unmanaged tests will run when deploying to a production org, regardless of the runalltests flag. The managed package tests only run if runalltests is set to true.

The SalesForce help explains it as:

In Production - if set to false, then managed package tests will not run but every other test will run. In Sandbox - if set to false, no tests will run.

So to summerize:

  • Setting runalltests to true will run all tests (managed/unmanaged) in all orgs
  • Setting runalltests to false will stop all tests (managed/unmanaged) from running in all orgs except for production where the unmanaged tests will always run
Related Topic