How can i get all the test classes name , body and method from salesforce to a external web service by using soap api callouts. Also i want to make request to run selected test method from webservice to salesforce. If there is any way, please help me.

  • You can explore tooling api :developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/… There you would be able to run test methods and also would be able to query all apex classes. I am not sure whether you can query for test classes or not but once you get all classes you can figure out which are test classes (by string contains method for testmethod, @isTest). Commented Dec 9, 2015 at 5:03
  • I tried tooling tooling api and also i am able to get all test classes by using sosl query and run those classes using runTest method but i want to run specific method of a test class
    – RaviKant
    Commented Dec 9, 2015 at 5:11
  • I don't think that you would be able to run one particular testMethod from testClass. If this is provided by platform then that would be great. Commented Dec 9, 2015 at 5:21

1 Answer 1


Per you last comment here is what you need to run specified tests using the tooling API (succinct since you said you were able to use tooling API to get classes):

/runTestsAsynchronous/ Body: {"tests":<tests array>}

Supported methods: POST

Runs one or more methods within one or more Apex classes, using the asynchronous test execution mechanism.

is an array of objects, each with two parameters:

  • classId—A String containing a test class ID. Each class ID can be listed only once.
  • testMethods—An array of Strings where each string represents the name of a test method in the test class specified by classId.

Multiple occurrences of a test method name in a testMethods array are ignored. Test methods that don’t exist are skipped. A null or missing testMethods array specifies that all test methods in the test class are run.


Or for Synchronous:

/runTestsSynchronous/ Body: {"tests":<tests array>}
  • Yes this is right. But we are doing through Soap API tool and it is taking as a string . How should i give the value in between the string format to run that particular test method of the test class. For ex :- <urn:runTestsAsynchronous> <urn:String>?</urn:String> </urn:runTestsAsynchronous>
    – RaviKant
    Commented Dec 9, 2015 at 9:27

You must log in to answer this question.

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