Courseiva

SF-PD2 · topic practice

Testing, Debugging, and Deployment practice questions

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.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Editorial oversight:Johnson Ajibi· MSc IT Security, IEEE Senior Member
20 questionsDomain: Testing, Debugging, and Deployment

What the exam tests

What to know about Testing, Debugging, and Deployment

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.

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

Watch out for

Common Testing, Debugging, and Deployment exam traps

  • ▸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

Practice set

Testing, Debugging, and Deployment questions

20 questions · select your answer, then reveal the explanation

A developer is preparing a large metadata deployment package using Salesforce CLI. Which TWO strategies should the developer implement to optimize deployment speed and minimize component locking issues? Choose 2 answers.

A developer writes a unit test class that queries millions of records to test a bulkified batch apex job. The test fails with a QueryException regarding result size limits. Which TWO best practices should the developer apply to write robust, scalable test data? Choose 2 answers.

A developer is optimizing an Apex test suite that runs slowly in the CI/CD pipeline. Which TWO techniques should the developer apply to improve test execution performance? Choose 2 answers.

A developer is writing a test class for a custom controller. The controller performs a DML operation that triggers an email alert. The developer needs to verify the email was sent without actually triggering an external SMTP server. Which approach is best?

A team is adopting a continuous integration (CI) pipeline for Salesforce. Which THREE tasks are essential for ensuring a successful, reliable deployment process?

A developer is writing a test that needs to mock a callout to an external REST API. What is the required interface for the mock class?

A developer needs to measure the performance of a method. Which approach provides the most accurate way to capture the CPU time consumed by that specific block of code?

Refer to the exhibit. The test is failing with a 'Too many SOQL queries' error. What is the most likely cause given the stack trace?

Exhibit

{
  "apex_test": "testAccountUpdate",
  "result": "fail",
  "message": "System.LimitException: Too many SOQL queries: 101",
  "stack": "AccountTriggerHandler.updateParent(AccountTriggerHandler.java:50)"
}

A developer is writing a test for a class that uses the 'with sharing' keyword. What THREE things must the developer keep in mind when writing tests for this class?

A developer is writing a test class for an Apex trigger and needs to verify that the trigger correctly updates a related record. Which approach ensures the test adheres to best practices regarding data isolation and governor limits?

When debugging a performance issue in a production environment, which tool is the most appropriate to inspect CPU time consumption and database query patterns?

Which THREE steps are necessary to ensure that a deployment using Change Sets includes all dependent components for a complex Apex class?

Which TWO of the following are true regarding the use of 'System.runAs()' in Apex unit tests?

A developer is writing a test class for a custom controller that performs complex DML operations. The developer needs to ensure that the test data does not persist in the database after the test execution finishes. Which approach should the developer use?

A developer is creating a Lightning Web Component and needs to debug issues that occur only in the production environment. Which TWO tools or features should the developer use to identify the root cause?

Refer to the exhibit. A developer encounters this error in a test method that processes a batch of records. What is the most efficient way to resolve this while ensuring the code remains testable?

Exhibit

Error: System.LimitException: Too many SOQL queries: 101

A developer is preparing a deployment from a Developer sandbox to a Full Copy sandbox. Which THREE steps are mandatory to ensure a successful and compliant deployment using Salesforce CLI?

A developer is investigating a race condition in a test class that interacts with asynchronous Apex. What is the best way to synchronize the test execution with the asynchronous operation?

A developer needs to optimize a test suite that is running slow in the CI/CD pipeline. Which TWO strategies should be implemented to reduce test execution time?

A developer needs to verify that an Apex trigger is correctly handling a bulk DML operation that involves 500 records. What is the most important practice to include in the test method?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Testing, Debugging, and Deployment sessions

Start a Testing, Debugging, and Deployment only practice session

Every question in these sessions is drawn from the Testing, Debugging, and Deployment domain — nothing else.

Related practice questions

Related SF-PD2 topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the SF-PD2 exam test about Testing, Debugging, and Deployment?
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.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Testing, Debugging, and Deployment questions in a focused session?
Yes — the session launcher on this page draws every question from the Testing, Debugging, and Deployment domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other SF-PD2 topics?
Use the topic links above to move to related areas, or go back to the SF-PD2 question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the SF-PD2 exam covers. They are not copied from any real exam or dump site.