DEVELOPMENT-LIFECYCLE-AND-DEPLOYMENT-ARCHITECT practice question 3 of 30

Universal Containers (UC) wants to shorten their deployment time to production by controlling which tests to run in production .UC's Architect has suggested that they run only subsets of tests. Which two statements are true regarding running specific tests during deployments? Choose 2 answers

Full set: 227 questions
Answer options
A: To run a subset of tests, set the Run Specified Tests test level on the DeployOptions objects and pass it as an argument to deploy() call. Correct answer
B: run a subset of tests ,set the RunLocalTests test level on the DeployOptions object and pass it as an argument to deploy() call.
C: Specify both test classes and individual test methods that are required to be executed as both are supported in DeployOptions.
D: Specifying the test method is supported in DeployOptions, therefore specify only the test classes that are required to be executed. Correct answer
Correct Answer:
A. To run a subset of tests, set the Run Specified Tests test level on the DeployOptions objects and pass it as an argument to deploy() call.; D. Specifying the test method is supported in DeployOptions, therefore specify only the test classes that are required to be executed.
Explanation

To shorten deployment times by running a subset of tests, the Metadata API's deploy() call must be configured correctly. The testLevel in the DeployOptions object should be set to RunSpecifiedTests (A). This instructs the platform to only execute the test classes listed in the runTests parameter of the DeployOptions object. The runTests parameter accepts an array of test class names; it does not support specifying individual test methods (D). Therefore, you must provide the names of the specific classes you want to run.

Why Incorrect

B. RunLocalTests is a different test level that runs all tests in the org except for those in managed packages; it does not run a specified subset.
C. Specifying individual test methods is not supported in the runTests parameter of the DeployOptions object for a Metadata API deployment.

References

1. Salesforce, Metadata API Developer Guide, "DeployOptions". The documentation specifies the testLevel enum, which includes RunSpecifiedTests. It states, "Only the tests that you specify in runTests are run."

2. Salesforce, Metadata API Developer Guide, "DeployOptions", runTests property. The documentation defines this property as "A list of Apex test classes to run during a deployment... Type: string[]". This confirms only class names are accepted.

3. Salesforce, Apex Developer Guide, "Running a Subset of Tests in a Deployment". This section explicitly states: "To run a subset of tests, set the testLevel deployment option to RunSpecifiedTests and specify the tests to run in the runTests option."

Scroll to Top