I want to run all the test classes in my org excluding any test classes from Managed package installation using Force migration tool aka ANT.

Looks like there used to be a task called sf:compileAndTest(as mentioned in this question) but I don't see that any more in salesforce official documentation here. May be this task is removed in the latest release.

Does anybody know a way to run all test classes(unmanaged) in the org using ANT?

P.S: I don't want to make any deployment. I just want to run the test classes to see what is the test coverage level. I don't want to run all the test classes from UI.


yes that is correct. sf:compileAndTest is no longer supported but you can run all test from sf:deploy task with the runAllTests="true" attribute, you don't need to actually deploy anything, though you will need a package.xml as per the documentation.

<!-- Shows check only; never actually saves to the server -->
<target name="deployCodeCheckOnly">
       <sf:deploy username="${sf.username}" password="${sf.password}"
        sessionId="${sf.sessionId}" serverurl="${sf.serverurl}"
        maxPoll="${sf.maxPoll}" deployRoot="dummy" testLevel="RunAllTestsInOrg"


<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
  • OK. So we are requesting ANT to run all tests like a normal deploy but we are not giving any files to deploy by specifying package.xml as empty. Is that correct? – javanoob Jan 6 '16 at 5:59
  • yes that is correct. It will run all the test methods and it will display code coverage at the end. – Himanshu Jan 6 '16 at 6:07
  • Excellent! Nice trick. – javanoob Jan 6 '16 at 6:20
  • Just to let you know it is not showing the test coverage of the org at the end. It is just showing the passed and failed class names thats it. – javanoob Jan 6 '16 at 6:22
  • I take that statement back. It is showing the overall test coverage of the org. Sorry for that confusion. Thanks for your time! – javanoob Jan 6 '16 at 6:27

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.