0

What are three ways for a developer to execute tests in an Org from the following options ?

  1. Bulk API
  2. Tooling API
  3. Setup Menu
  4. SalesforceDX
  5. MetaData API

In my opinion, it should be Tooling API, Setup Menu, and MetaData API. Because -

Setup Menu - By browsing to setup->Apex Test Execution
Tooling API - You can also run tests using the Tooling REST API. Use the /runTestsAsynchronous/ and /runTestsSynchronous/ endpoints to run tests asynchronously or synchronously.
MetaData API - Not sure about it. But found a link - Unit tests executed via metadata API failing on call to system.test.startTest

Reference link- https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_unit_tests_running.htm

Also how can a developer check the test coverage of active Process Builder and Flows before deploying them in a change set?

Please suggest your opinion with references and steps to produce. Thanks

2 Answers 2

3

Setup Menu, Tooling API and SalesforceDX.

The link you provided mentions that as well (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_unit_tests_running.htm)

Running Tests Through the Salesforce User Interface

Running Tests Using the Salesforce Extensions for Visual Studio Code

VS Code uses sfdx.

Running Tests Using the API - You can also run tests using the Tooling REST API.

Regarding coverage, have a look at the following link:

https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_forcecom_flow_test_coverage.htm

2

You can execute Test classes in apex by inserting a record of ApexTestQueueItem

Insert new ApexTestQueueItem(ApexClassId=[SELECT Id FROM ApexClass WHERE Name='OportunityTriggerHandlerTest'][0].Id);

And then check results as

[SELECT Id,ApexClass.Name,ApexTestRunResult.ClassesCompleted FROM ApexTestResult];

Regarding testing flows. You just run normal apex classses and then see coverage by querrying FlowTestCoverage and FlowElementTestCoverage

You must log in to answer this question.

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