8

I am planning to run SFDC tests for Default namespace in sandbox my build file is as follows -

<target name="RunTestDefaultNamespaceSandbox">
  <sf:compileAndTest username="${sf.username}" password="${sf.password}" serverurl="https://test.salesforce.com">
    <runTests namespace="Default"/>
  </sf:compileAndTest>
</target>

I am getting error when I execute this as follows -

Run All Test - /build.xml:31: sf:compileAndTest doesn't support the "serverurl" attribute   

I do not want to run test for all classes (appxhcnage classes should be excluded) Thanks in advance.

7

== See duplicate post: https://salesforce.stackexchange.com/posts/76899/edit ==

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][1]

| improve this answer | |
1

The current version of the toolkit's compileAndTest task appears to work with both "server" and "serverurl" attributes, which indicates you are not on the current version. If you're using an old version of the Ant Force.com Migration toolkit (likely), try changing "serverurl" to "server", which I think used to be the attribute name. Or even better, upgrade to the latest version of the Migration toolkit.

| improve this answer | |
  • I updated to latest version of ANT and build got executed, but it still runs all tests in my org. Any idea on how to run only classes in default namespace ? – Prafulla Patil Jun 19 '13 at 19:16
  • @PrafullaPatil Did you get this to working now? i have the same issue <runTests namespace="Default"/> is set but it runs all tests in my org including managed packages – Sven Delporte Feb 6 '14 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.