0

i'm deploying a destructive change (includes apex classes) into a production environment and it kick starts running all tests. This didn't happen when doing it on the sandbox environments. Any way I can bypass this or even running specified tests?

11
  • 1
    You need to verify if you were using the same ant task in your sandbox and production environment. You cannot bypass tests in production, but if you have right ant task, you can always specify specific tests.
    – Jayant Das
    Oct 19, 2018 at 19:22
  • so would I specify tests for the classes being deleted?
    – JPG
    Oct 19, 2018 at 19:31
  • You cannot run "Specified" tests while deploying anything to prod.... Oct 19, 2018 at 19:34
  • @SebastianKessel - You can specify in production as well.
    – Jayant Das
    Oct 19, 2018 at 19:41
  • I'll be damned. Good Catch. Oct 19, 2018 at 19:42

1 Answer 1

3

Unfortunately, there isn't. Every time you push any type of code to a production environment Salesforce is going to force the deployment to RunAllTests. In sandboxes this is a value you can control, but not on production. This is to ensure that all code compiles and your tests still work after destructing.

As an example, imagine accidentally removing a trigger that impacts your application's behavior. Tests running would ensure that you catch that problem before your production org starts failing.

This document contains more details. Please note that a "destructive deployment" is still a deployment and thus has to comply with the same rules.

Here is the relevant excerpt:

When deploying to production, all tests, except those that originate from managed packages, are executed if your deployment package contains Apex classes or triggers. If your package doesn’t contain Apex components, no tests are run by default.

EDIT:

Thanks to @JayantDas, you can run Specified Tests on a prod deploy. See here. The big caveat is that every single class you test has to meet the 75% threshold. With "All Tests" it's a combined 75% (except for triggers).

3
  • Would I be able to run specified tests on a destructive changes xml?
    – JPG
    Oct 19, 2018 at 19:30
  • Nope. It's all unmanaged tests. You have no control over this. Oct 19, 2018 at 19:31
  • Not sure which tool you are using, but generally you should be able to push destructive changes + run specific test class. In such case, you can simply mentioned 1 test class which you know it is valid. + With that being said, you should be careful about this process, as deleting some code might reduce your coverage and therefore might cause for future errors in the next deployments.
    – Liron C
    May 12, 2020 at 9:27

You must log in to answer this question.

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