1

So I wrote a C# program that uses the Salesforce Tooling WSDL to call RunTestsRequest . I got that working the only problem I have is the the test results only show up in Apex Test Results and not Apex Test Execution. How can I get tests to run in Apex Test Execution via API?

3

There are two ways of running Apex tests in Salesforce:

  1. Synchronously
  2. Asynchronously

The runTests() method in the Tooling API is synchronous. It will run the tests while you wait and then return the results.

This differs from runTestsAsynchronous(), which unsurprisingly runs the tests asynchronously. In this case you need to poll for the test outcomes.

The other big difference is that only the asynchronous version will result in the ApexTestResult and associated records. It is these records that drive the Apex Test Execution in the Salesforce UI.

So, short answer, try switching to running the test async if you want to do things like check the resulting code coverage.

  • Thank you for the response I'll give it a shot when I get back to Work on Monday. – Halfwarr Jul 29 '17 at 5:15
  • 1
    Yep that worked! – Halfwarr Jul 31 '17 at 16:30

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.