Find your content:

Search form

You are here

is there a possibility for Run all tests (in target sandbox) before deployment?

 
Share

is there a possibility for Run all tests (in target sandbox) before deployment from my dev sandbox? If so how to do that?

I have about 700 components in my changeset and its successfully validated. But I read in SF help that run all test have to be done manually.

If that is the case after I deploy and say run all tests, and if it fails, is a possiblity to roll back?

(or)

Can I do a run all tests after validating my changeset somehow? (i know its foolishness to ask this question because it might not have the components to run all tests. just wanted to know if there is tweak somehow? :) )


Attribution to: Sathya

Possible Suggestion/Solution #1

I'm happy to report that as of Summer '15 (v34.0) there is now a testLevel parameter on the sf:deploy command so if you're using the Summer '15 version of ant-salesforce.jar you can now specify:

<target name="deployCodeCheckOnly">
  <sf:deploy 
    testLevel="RunLocalTests"
    username="username@username.be.full" 
    password="password" 
    serverurl="https://test.salesforce.com" 
    maxPoll="500" 
    deployRoot="codepkg" 
    checkOnly="true"/>
</target>

This will specifically exclude any Managed Package tests from running. There are a number of other changes to the test options for deployments in Summer '15 that you can read about here. The available testLevel options are:

  • NoTestRun—No tests are run. This test level applies only to deployments to development environments, such as sandbox, Developer Edition, or trial organizations. This test level is the default for development environments.
  • RunSpecifiedTests—Only the tests that you specify in the runTests option are run. Code coverage requirements differ from the default coverage requirements when using this test level. Each class and trigger in the deployment package must be covered by the executed tests for a minimum of 75% code coverage. This coverage is computed for each class and trigger individually and is different than the overall coverage percentage.
  • RunLocalTests—All tests in your organization are run, except the ones that originate from installed managed packages. This test level is the default for production deployments.
  • RunAllTestsInOrg—All tests are run. The tests include all tests in your organization, including tests of managed packages

See the Force.com Migration Tool documentation


Attribution to: abd3721

Possible Suggestion/Solution #2

You can force a run of all tests when deploying using the Force.com migration tool which is a wrapper over Ant. Set runAllTests=true when deploying to simulate a production like deployment where all tests are run while deploying. To rollback if test classes fail, set the rollBackOnError deployment option to true.

Here is the reference documentation, look around page 17 (Deploying Code) http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf


Attribution to: techtrekker

Possible Suggestion/Solution #3

I was getting an error complaining that testLevel wasn't a valid parameter - turned out I had copied the ant.salesforce.jar to my ant/lib directory when I first configured the migration tool - I deleted it and reference the jar from within build.xml - works fine now. Keep that in mind if you upgrade to v34 of the migration tool that you should do a quick sweep of your system to make sure you don't have older versions of the jar out there in the classpath somewhere.


Attribution to: Michael DeMeglio
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/3298

My Block Status

My Block Content