I have a directory of apex classes, checked into version control, that I need to be able to programatically delete and then re-deploy into a Salesforce Sandbox. I do not want to deploy to production, I just need a quick way to delete all of these files.

So I tried to use the force.com deploy tool to deploy the sample code to my SANDBOX, and it won't let me because of code coverage. Why is this? Is the deploy tool trying to ALSO deploy to production? Why would it do that? Is the deploy tool not meant to be able to deploy local files to a sandbox environment?

EDIT: I have verified that my login credentials are valid by executing ant describeMetadata successfully. Also, my serverurl is set to https://test.salesforce.com

EDIT 2: I commented out the following line from the deployCode target in the sample build.xml <runTest>SampleDeployClass</runTest>

And the deploy worked! Why though? Why would that for some reason affect whether code coverage matters for the rest of the classes in the sandbox?

  • Deploying to a sandbox should work without test code coverage. I would encourage you to check your login credentials again.
    – greenstork
    Sep 26, 2014 at 21:05
  • I have set my sf.serverurl to test.salesforce.com, and I am able to successfully execute ant describeMetadata
    – atmdd
    Sep 26, 2014 at 21:10
  • Also, I have set runAllTests to "false" in the sample build.xml file.
    – atmdd
    Sep 26, 2014 at 21:13

3 Answers 3


If the tests are run they are not only run - but also their results will be taken into account. That means a rollback on failure. Not meeting the test coverage counts as failure and you get your rollback.

Not running the tests as you set it up now brings you another advantage: you could save a lot of time, since tests may slow down the deployment significantly.

But if you want the tests for some reason to be run I would recommend to do it separately after deployment in the background. Either manually or automated but decoupled from this process.


Usually for sandbox deployment, salesforce doesn't run all tests. It may be because the deployment tool, is trying to run all tests. But I'm sure salesfore doesn't run all tests in sandboxes :)


Quick addition to this, if you're deploying to a sandbox, don't run any specified test, just leave it to default and it won't require coverage to deploy.

If you run a specified test, then the default requirement of 75% coverage becomes active again

You must log in to answer this question.

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