Apex Tests Run While Deploying
Test Level Deploy Options
- No Test Run (no Apex tests are run unless it is a production deployment).
- Run Specified Tests: Only included Apex test classes are run (aka fast deploy). These test classes are:
- Classes that were committed in user stories that are part of the deployment.
- Classes that are added to user stories that are part of the deployment through the button Add Test Classes.Note: Classes added by clicking on Add Test Classes are stored in a json file in the deployment, which can later be modified if required.
- Run Local Tests (all Apex test classes excluding managed packages are run).
- Run All Tests In Org (all Apex test classes including managed packages are run).
When deploying to production, Salesforce does not allow No Test Run, and it will force a Run Local Tests. Also when deploying to production, it is possible to use the option Run Specified Tests. However, in order to benefit from this option, you will need to include in the same step all together the Apex classes and the Apex test classes which must provide at least 75% of coverage of the code being deployed.
For more information about the test levels that are applied when working with Copado, please check out the article What Test Level Is Applied and Where When Working with Copado?
Bear in mind that if you are using Copado Continuous Integration and the option Run All Tests, Copado will enforce Run Local Tests. Again, if you have edited the environment record and selected the option Run All Tests, in any deployment to that environment Copado will enforce Run Local Tests.
For more information, please refer to Salesforces' documentation.