Skip to content

Instantly share code, notes, and snippets.

@tyoshikawa1106
Created June 19, 2016 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyoshikawa1106/5ab250349f7026ca3428525acc04136a to your computer and use it in GitHub Desktop.
Save tyoshikawa1106/5ab250349f7026ca3428525acc04136a to your computer and use it in GitHub Desktop.
開発者コンソールから動かすTooling API
String requestBody = '{';
requestBody += ' "tests": [';
requestBody += ' {';
requestBody += ' "classId": "01p10000001lEPV",';
requestBody += ' "testMethods": ["Summer16ApexDemoControllerTest1","doSerializeJsonTest1", "doSerializePrettyJsonTest1"]';
requestBody += ' }';
requestBody += ' ]';
requestBody += '}';
System.debug(requestBody);
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
req.setHeader('Content-Type', 'application/json');
req.setBody(requestBody);
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v37.0/tooling/runTestsAsynchronous');
req.setMethod('POST');
HttpResponse res = http.send(req);
System.debug(res);
String result = res.getBody();
System.debug(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment