I am trying to get rid of some old apex code in a Salesforce org. There are few test classes on production org which are broken because 1) they were written a few years back with old API version or 2) configuration changes made to the org like few users are inactive now

Tried to comment out the code in these classes and dependant classes on sandbox. Verified that sandbox has 82% code coverage after these changes and production has 79% code coverage. But when I try to deploy these changes using gearset to production org, it fails because of an error - “Code Coverage Failure - Your code coverage is 69%. You need at least 75% coverage to complete this deployment.” I tried different combinations/order of deployment but that also fails because of inter dependencies.

I have not yet tried IDE for deployment and would prefer to not use it there is some workaround with gearset or changesets.


  • 1
    Have you tried Run Specific Tests and selected enough test classes to cover the real code classes that you're deploying? Remember you can include test classes in your deployment set but also test classes that are not part of the set. If you're not getting enough code coverage in the specific classes you're deploying, you'll need to write more unit tests. – David Cheng Aug 9 '19 at 0:25
  • I have not yet tried running specific tests. There is code in few test classes on production which is broken and my set includes those classes with fixed. So if I choose these test classes to run while deploying, my guess is that it will still fail. Is that correct? – Anum Goel Aug 9 '19 at 20:34
  • what do you mean by "still fail" -- do you mean not enough code coverage? – David Cheng Aug 10 '19 at 3:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.