Be able to write Apex tests that isolate data, create users with System.runAs, and verify asynchronous logic by wrapping it in Test.startTest and Test.stopTest. For deployment, use Salesforce DX with version control and scratch orgs so releases are repeatable and validated before production.
Start practicing
Testing, Debugging, and Deployment — choose a session length
Free · No account required
Domain overview
This domain covers Apex testing patterns, debugging tools, and deployment mechanics on the Salesforce Platform. Questions present realistic developer scenarios and ask you to select the correct tool, test approach, or deployment practice, so you must know when to use Developer Console, checkpoints, debug logs, Test. startTest/stopTest, and Salesforce DX commands.
Exam objectives
Using Developer Console checkpoints and debug logs to inspect variables and trace execution paths
Testing asynchronous Apex with Test.startTest and Test.stopTest to force background job execution
Creating test users with System.runAs and required profile or permission set access
Salesforce DX deployment practices including scratch orgs, unlocked packages, and source tracking
Assuming asynchronous Apex runs during a test without wrapping it in Test.startTest and Test.stopTest, so assertions execute before the job finishes
Querying or creating users directly in tests instead of using System.runAs with a properly configured test user and permissions
Treating change sets or manual metadata retrieval as repeatable deployment methods instead of using Salesforce DX source tracking and version control
Click any question to see the full explanation and answer options, or start a focused practice session above.
A developer needs to write a unit test for an asynchronous future method that updates account records. How should the developer structure the test to ensure the asynchronous code executes and validates correctly?
2A developer wants to inspect private variable states and trace execution paths of a complex trigger framework during a sandbox debugging session. Which tool should the developer use to capture this diagnostic information?
3An enterprise development team uses Salesforce DX scratch orgs for feature development. A developer needs to ensure that unit tests execute automatically every time code is committed to the version control system. Which integration approach achieves this requirement?
4Refer to the exhibit. A developer encounters this error message while deploying an updated trigger to a production environment. What is the most effective approach to diagnose and resolve this deployment failure?
5A developer is refactoring a large legacy trigger. They want to ensure performance does not degrade while maintaining test coverage. Which TWO practices should be followed to ensure high-quality, performant testing?
6Refer to the exhibit. A developer attempts a deployment using Salesforce CLI. The deployment fails with the circular dependency error shown. What is the root cause of this failure?
7A developer is creating a custom exception to handle business logic errors. What is the correct way to declare this exception so it can be caught specifically in a try-catch block?
8Refer to the exhibit. A developer encounters a 'Maximum stack depth reached' error. What is the most likely cause of this recursive error?
9Which TWO statements are true regarding the use of 'System.debug()' in a production environment?
10What is the best way to test asynchronous Apex (Future methods, Queueable) to ensure the logic within the background job actually executes?
11A developer wants to log information to the Debug Log for a specific class only, without cluttering the logs for the entire organization. What is the most efficient way to achieve this?
12Refer to the exhibit. A developer encounters this error during a unit test. What is the most likely cause, and how should it be resolved?
13A developer is preparing for a deployment using Salesforce DX. Which TWO practices are recommended to ensure successful and repeatable deployments?
14A developer wants to ensure that their Apex code is tested against a specific set of data that is consistent across all sandbox environments. What is the best way to achieve this?
15A developer is writing an Apex class that needs to handle high volumes of data. Which pattern should they follow to avoid hitting Governor Limits?
16Refer to the exhibit. A deployment is failing with this error. What is the most likely cause?
17Which of the following is an advantage of using a 'Source-Driven' development model over an 'Org-Centric' model?
18Refer to the exhibit. A developer encounters this policy during a deployment attempt via the CI/CD pipeline. What does this indicate about the deployment process?
19Which command is used in the Salesforce CLI to retrieve metadata from an org to a local project?
20Refer to the exhibit. A developer wants to enable log filtering for a specific package. Where should this configuration be managed?
21Refer to the exhibit. A developer encounters this error while performing a bulk update of 200 Account records. What is the root cause of this exception?
22A developer needs to deploy a complex Apex class and its corresponding test class to production. The org's unit test coverage is currently 74%. Which statement accurately describes the deployment requirements?
23Refer to the exhibit. A developer is deploying code using the Salesforce CLI. What is the most likely reason for this failure?
24A developer needs to verify that an asynchronous Apex process (Future method) executes correctly in a test environment. Which approach is best suited to ensure the test waits for the asynchronous execution to finish before asserting the results?
25During a deployment, a developer notices that existing Apex tests are failing, even though the new code changes are unrelated to the failing tests. What is the most likely cause?
26A developer is attempting to debug a failed deployment in a sandbox. The error message is cryptic, and the debug logs are not capturing the expected execution flow. What should the developer do first?
27A developer needs to measure the performance of a specific Apex code block in production. Which tool should be used to analyze CPU time without impacting end-user experience?
28A developer is writing a test class that requires a user with a specific profile. How should the developer handle the user creation process?
29A developer is writing a test class for an Apex trigger that performs a callout. The developer uses a mock class implementing HttpCalloutMock. What happens if the developer fails to implement the mock interface correctly?
30Refer to the exhibit. A developer encounters this LimitException in a bulkified trigger. What is the most likely cause based on the provided stack trace?
31A developer needs to deploy a new Apex class to production that makes a callout to an external REST service. The callout must be made from a trigger. During testing in a sandbox, the developer writes a test class that performs DML to insert a record that fires the trigger, but the test fails with a 'CalloutException: Methods defined as TestMethod do not support Web service callouts' error. What should the developer do to allow the test to execute the callout successfully?
32A developer is preparing to deploy a complex change set from a sandbox to production. The change set includes Apex classes, Visualforce pages, and a new custom object. The developer runs all tests in the sandbox and achieves 100% coverage, but the deployment to production fails with the error: 'Your organization's code coverage is 68%. You need at least 75% coverage to complete this deployment.' What is the most likely cause of this discrepancy?
33A developer deploys metadata to a production org using the Salesforce CLI. The deployment succeeds, but a post-deployment validation script that relies on a newly created custom setting record fails because the record is missing. The developer confirms the custom setting metadata was included in the package. What is the most likely explanation?
34A developer is writing an Apex test class for a service that must be resilient against partial failures. The service calls a REST endpoint using a callout and, when the callout succeeds, performs a DML update on a set of Account records. The developer wants the test to simulate the HTTP response without hitting the real external system. Which approach should the developer use?
35A developer is troubleshooting an Apex class that intermittently throws a System.LimitException during integration tests. The developer needs to see the exact sequence of method calls and the values of variables at each step without modifying the class. Which Salesforce feature should the developer use?
36A developer must write Apex tests that reliably cover a Queueable class which performs a callout and then enqueues a second Queueable job. The tests must not make real external callouts. (Choose two.)
37A developer has written an Apex class that includes a method to calculate shipping costs. The method contains several conditional branches. The developer wants to ensure that all branches are tested and that the test class provides sufficient coverage for deployment. Which Salesforce feature should the developer use to identify which lines of code are not covered by tests?
38A developer needs to run a single Apex test method named testBulkInsert in a class named AccountServiceTest against a sandbox org and view the results from the command line. Which Salesforce CLI command should the developer use?
39A developer is deploying a new Apex class to production using a change set. The class contains a method that performs a callout to an external web service. During deployment, the developer receives an error: 'Callout not allowed from a test method.' Which action should the developer take to resolve this error while ensuring the test method still validates the callout logic?
40A developer is preparing to deploy a change set from a sandbox to production. The change set includes a new custom object, its fields, a Visualforce page, and an Apex controller. After uploading the change set, the developer notices that the custom object and fields are missing from the change set components. What is the most likely reason?
41A developer is preparing an Apex test class that must cover a service which schedules a Queueable job, and the test must verify that the queued job's logic actually ran and updated a record. The developer also needs the test to pass reliably in a CI pipeline. (Choose two.)
42A developer is preparing a deployment of a new Apex class and its test class to production. The test class uses @TestSetup to insert 200 Account records, and each of six test methods queries all 200 Accounts. The deployment fails during validation with a CPU timeout error. Which change most directly addresses the timeout without reducing coverage?
43A developer maintains a managed package and must release a new version. During packaging, the developer needs to ensure that a specific Apex class is accessible to subscriber orgs but that its implementation details remain hidden. Which packaging construct should the developer use?
44A developer is writing a test class for a service that makes callouts to an external web service. The test method needs to simulate the callout response without making an actual HTTP request. (Choose two.)
45A developer is debugging an Apex class that is failing in production. The developer wants to capture debug logs for a specific user without affecting other users. Which tool should be used to set up a trace flag for that user?
46A developer is preparing a managed package for release and needs to validate that the package's Apex code does not exceed the per-transaction limits enforced by the platform. The developer wants to run the packaged test suite in a scratch org and see the exact number of SOQL queries and DML statements consumed during each test. Which approach best satisfies this requirement?
47An integration test in a sandbox must verify that a callout to an external pricing service returns a parsed response. The test class currently attempts the real callout and fails with a 'Methods defined as TestMethod do not support Web service callouts' error. Which change should the developer make?
48A developer is deploying a new Lightning web component that calls an Apex controller method. The deployment to production fails because the Apex class is not covered by tests. The developer needs to ensure the Apex class meets the 75% test coverage requirement and that the tests are robust. Which two actions should the developer take to achieve this? (Choose two.)
49A developer is troubleshooting a production issue where a trigger occasionally exceeds CPU time limits. The developer wants to capture detailed debug logs for a specific user without slowing down the entire org, and then analyze the log to identify the slowest operations. Which combination of Salesforce tools should the developer use?
50A developer is debugging why a trigger fires twice for a single record save in a sandbox. The trigger is defined on Account with `before insert, after insert` and the class uses a static Boolean guard variable to prevent recursion. Logs show two separate transactions. Which explanation best fits this behavior?
51A developer is writing a test class for a service that makes a callout to an external REST API. The test must not perform a real callout, and the developer needs to verify that the service correctly handles both a successful response and an error response. Which approach should the developer use?
52A developer is writing an Apex test class for a service that calls an external REST endpoint via a callout. The test must verify the parsing logic without hitting the external system, and it must also assert that the service throws a custom exception when the endpoint returns a 500 status. Which combination of techniques is required?
53A developer needs to give a CI service account the ability to run the Apex test suite in a production org without interactive login, and the pipeline must not store a user's personal password. Which authentication approach should the developer configure?
54A developer is writing an Apex test method for a service class that makes a callout to an external REST API. The test must not perform the actual callout. The developer creates a static resource containing the JSON response and writes a mock class that implements HttpCalloutMock. Which statement must the developer include in the test method to register the mock before the callout is executed?
55A developer is writing an Apex test class for a service that calls an external REST API using a Named Credential. The test must not make real callouts, and the developer wants to verify that the correct endpoint and body are sent. Which approach should the developer use?
56A developer is preparing to deploy a change set from a sandbox to production. The change set includes an Apex class that references a new custom field on Account. The deployment fails with a 'field does not exist' error. What is the most likely cause and the correct action?
57A developer needs to debug an Apex trigger that intermittently fails in production with a 'UNABLE_TO_LOCK_ROW' error when multiple users update related records. Which technique should the developer use to capture the detailed execution context and identify the conflicting transaction?
58A developer is writing an Apex test class for a controller that uses a Visualforce page with a standard controller. The test must cover pagination logic that relies on the StandardSetController. Which TWO actions should the developer take to ensure the test is reliable and covers the pagination behavior? (Choose two.)
59A developer is using the Salesforce CLI to deploy a set of Apex classes and a custom object to a sandbox. The developer wants to validate the deployment without saving any changes to the target org. Which command should the developer use?
Be able to write Apex tests that isolate data, create users with System.runAs, and verify asynchronous logic by wrapping it in Test.startTest and Test.stopTest. For deployment, use Salesforce DX with version control and scratch orgs so releases are repeatable and validated before production.
The Courseiva SF-PD2 question bank contains 59 questions in the Testing, Debugging, and Deployment domain. Click any question to see the full explanation and answer breakdown.
Start with a 10-question focused session to identify your baseline accuracy in this domain. Read every explanation — even for questions you answer correctly — to understand the reasoning. Once you score consistently above 80%, move to a 20–30 question session to confirm depth before moving to the next domain.
Yes — the session launcher on this page draws questions exclusively from the Testing, Debugging, and Deployment domain. Choose 10, 20, 30, or 50 questions for a focused session, or click individual questions to review them one by one.
Save your results, see per-domain analytics, and get readiness scores — free, for every certification.
Sign Up FreeFree forever · Every certification included