TransWikia.com

Deactivating Trigger in Production with SFDX, will all test classes run?

Salesforce Asked by Bobbygllh on December 12, 2020

I am trying to deactivate a single trigger from our Production environment and am wondering if all test classes need to run like when you try to delete classes. I am referencing thisSF article and using sfdx force:mdapi:deploy.

2 Answers

Yes, all test classes will run in order to meet the test coverage requirement as that is considered to be a deployment. "All" here, by default, means all tests in your organization except the tests that originate from installed managed packages. If a subset of tests is specified, it means all the specified tests.

The reasoning is that with this trigger disabled, other Apex code might or might not be executed. The code coverage becomes unknown. Therefore, it needs to be re-calculated based on the state of a new test run.

Answered by Chun on December 12, 2020

If we refer to the documentation for the sfdx force:mdapi:deploy command :

-l | --testlevel TESTLEVEL Optional Specifies which level of deployment tests to run. Valid values are:

NoTestRun—No tests are run. This test level applies only to deployments to development environments, such as sandbox, Developer Edition, or trial orgs. This test level is the default for development environments.

RunSpecifiedTests—Runs only the tests that you specify in the --runtests option. Code coverage requirements differ from the default coverage requirements when using this test level. Executed tests must comprise a minimum of 75% code coverage for each class and trigger in the deployment package. This coverage is computed for each class and trigger individually and is different than the overall coverage percentage.

RunLocalTests—All tests in your org are run, except the ones that originate from installed managed packages. This test level is the default for production deployments that include Apex classes or triggers.

RunAllTestsInOrg—All tests in your org are run, including tests of managed packages.

If you don’t specify a test level, the default behavior depends on the contents of your deployment package. For more information, see “Running Tests in a Deployment” in the Metadata API Developer Guide.

You can basically specify the TestLevel you want to apply.

Bear in mind that when deploying to production orgs, NoTestLevel is not a valid option. But you never need to run all test classes.

I would suggest to just run the specified test classes. It should be enough if you specify even just 1 test class as long as the coverage for your trigger is greater than 75%

Answered by Gabriel Serrano Salas on December 12, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP