+ Start a Discussion
System Administrator 393System Administrator 393 

Deploying to Production

I pushed an Apex Class and Trigger to production but my TestClass is in sandbox, when the tests are run in production before deployment, does it run all tests from production, sandbox or both?
@anilbathula@@anilbathula@
Hi system administrator 393,

Test class are organisation specific.
if you run test in live it won’t run in sandbox.
you need to push your test class along with class or trigger to live and run the test class in live for deployment .

Thanks
Anil.B
 
Raj VakatiRaj Vakati
You test class will run on the Target org data based on the source code whihc include in change ste 


user can choose which tests to run when validating an inbound change set in production or sandbox at the time of deployment. Test options provide flexibility in how much testing is done to achieve quality and code coverage requirements which will reduce execution time in a deployment. This feature is available in both Lightning Experience and Salesforce Classic.'


> Default : It keeps the default behavior for all tests. In sandbox, no tests are executed. In production, all local tests are executed if change set contains Apex classes or triggers.Local tests are all tests, except the ones that originate from managed packages. If package doesn’t contain Apex components, no tests are run.
-> Run Local Tests : In this all tests in organization 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.
-> Run All Tests : In this all tests in organization are run, including tests of managed packages.
-> Run Specified Tests : Only the tests that user specify are run.User has to provide the names of test classes in a comma-separated list. Benefit of choosing this option is that it checks code coverage criteria at the Changeset level rather than checking it at the entire org level. The executed tests must cover the classes or triggers contained with in change sets with a minimum of 75% code coverage. This coverage is computed for each class or trigger individually and is different from the overall coverage percentage.

 
Bavadharani GanesanBavadharani Ganesan
Hi System Administrator 393,
It is the best practice to use Run Specified Test if your Apex class has a test class. Otherwise, it will run all the test classes in the destination org(production). Did you got it?