Praxis Academy
Home › Platform Developer › Testing, Debugging, and Deployment

Platform Developer practice questions: Testing, Debugging, and Deployment

Testing, Debugging, and Deployment is 20% of the Salesforce Certified Platform Developer exam. It covers test classes, code coverage, debug logs, sandboxes and deployment tools. Try these 15 free questions, then open each answer to see why every option is right or wrong.

01

A developer starts an asynchronous job with System.enqueueJob() and stores the returned job ID. Which two options can the developer use to monitor whether the job is queued, processing, completed, or failed? Choose 2 answers.

Choose two.

  1. The Apex Jobs page in Setup, which lists asynchronous jobs and their status.
  2. A SOQL query on AsyncApexJob filtered by the ID returned from System.enqueueJob().
  3. The Apex Flex Queue page, which shows all Queueable jobs while they are running.
  4. The Scheduled Jobs page in Setup, which lists every asynchronous job type.
Show answer

Answer: A, B

A. The Apex Jobs page in Setup, which lists asynchronous jobs and their status. ✓Correct. The Apex Jobs page shows Queueable, Batch, and future jobs with their current status.
B. A SOQL query on AsyncApexJob filtered by the ID returned from System.enqueueJob(). ✓Correct. Querying AsyncApexJob by the returned ID gives Status, NumberOfErrors, and other details.
C. The Apex Flex Queue page, which shows all Queueable jobs while they are running.The Apex Flex Queue holds Batch Apex jobs waiting to be processed; it does not track Queueable jobs.
D. The Scheduled Jobs page in Setup, which lists every asynchronous job type.Scheduled Jobs shows scheduled Apex and similar scheduled items, not the status of enqueued Queueable jobs.

Why: System.enqueueJob() returns the ID of an AsyncApexJob record. Its status can be viewed on the Apex Jobs page in Setup or queried programmatically from the AsyncApexJob object.

02

A developer wants to run every Apex test in the org after a set of changes. Which three options can be used to run Apex tests? Choose 3 answers.

Choose three.

  1. The Tooling API
  2. The Bulk API
  3. The Metadata API, as part of a deployment or validation
  4. The Apex Test Execution page in Setup
  5. The Data Import Wizard
Show answer

Answer: A, C, D

A. The Tooling API ✓Correct. The Tooling API can start test runs and return the results.
B. The Bulk APIThe Bulk API loads and extracts large data volumes; it cannot run tests.
C. The Metadata API, as part of a deployment or validation ✓Correct. A deployment or validation through the Metadata API can run specified or all tests.
D. The Apex Test Execution page in Setup ✓Correct. Apex Test Execution in Setup lets you select and run test classes.
E. The Data Import WizardThe Data Import Wizard imports records; it cannot run tests.

Why: Apex tests can be started from the Setup UI, from the Developer Console, through the Tooling API, through the Metadata API during a deployment, and with Salesforce CLI, which uses these APIs.

03

Some code runs without errors in Execute Anonymous in a sandbox, but the same logic fails when run as an Apex test. What is the most likely reason?

  1. The code calls a future method, which never runs in a test.
  2. Execute Anonymous does not enforce governor limits.
  3. The code depends on records that exist in the sandbox but are not visible in the isolated test context.
  4. Execute Anonymous ignores compilation errors.
Show answer

Answer: C

A. The code calls a future method, which never runs in a test.Future methods do run in tests, for example when Test.stopTest() is called.
B. Execute Anonymous does not enforce governor limits.Governor limits apply in Execute Anonymous as well.
C. The code depends on records that exist in the sandbox but are not visible in the isolated test context. ✓Correct. Tests run without access to org data unless they create it or use SeeAllData.
D. Execute Anonymous ignores compilation errors.Code with compilation errors cannot run in either context.

Why: By default, Apex tests cannot see existing org data. Code that relies on records already in the sandbox works in Execute Anonymous but fails in tests unless the test creates the data it needs.

04

A trigger on Delivery__c is creating duplicate Tracking_Event__c records. What is the most practical first step to find the cause?

  1. Add System.debug() statements to the trigger and review the debug log to trace the logic.
  2. Deactivate the trigger in production to see whether the duplicates stop.
  3. Review Event Monitoring logs to see which users caused the issue.
  4. Purchase and use the Apex Interactive Debugger in production.
Show answer

Answer: A

A. Add System.debug() statements to the trigger and review the debug log to trace the logic. ✓Correct. Debug statements show the values and code paths that produce the duplicates.
B. Deactivate the trigger in production to see whether the duplicates stop.Deactivating the trigger stops required processing and does not explain the cause.
C. Review Event Monitoring logs to see which users caused the issue.Event Monitoring shows user activity, not the trigger's logic.
D. Purchase and use the Apex Interactive Debugger in production.The interactive debugger is not the most practical first step.

Why: Adding debug statements and reviewing the resulting log is a quick, low-risk way to see variable values and how many times the logic runs. Tools such as the Apex Replay Debugger can then help step through the log.

05

A team wants to automate deployments to a sandbox as part of a CI/CD pipeline. Which two options support scripted deployments? Choose 2 answers.

Choose two.

  1. Salesforce CLI, with commands such as sf project deploy start
  2. Visual Studio Code tasks that run Salesforce CLI commands
  3. Workbench
  4. Change sets
Show answer

Answer: A, B

A. Salesforce CLI, with commands such as sf project deploy start ✓Correct. CLI deploy commands can be scripted in a pipeline.
B. Visual Studio Code tasks that run Salesforce CLI commands ✓Correct. VS Code can run CLI commands from tasks and its terminal.
C. WorkbenchWorkbench is interactive and not suited to scripted pipelines.
D. Change setsChange sets are built and deployed manually in Setup.

Why: Salesforce CLI commands can be scripted, and VS Code can run them through its terminal or tasks. Workbench and change sets are manual, UI-based tools.

06

After running all tests in a sandbox, a developer wants to see the code coverage for the WarehouseService class. What is the most direct way?

  1. Open the Setup Audit Trail and filter for the class.
  2. In the Developer Console, check the Overall Code Coverage panel on the Tests tab.
  3. Run the class in Execute Anonymous and look for coverage in the debug log.
  4. Open the Test Coverage dashboard in Lightning App Builder.
Show answer

Answer: B

A. Open the Setup Audit Trail and filter for the class.The Setup Audit Trail records configuration changes, not coverage.
B. In the Developer Console, check the Overall Code Coverage panel on the Tests tab. ✓Correct. The Tests tab lists coverage for every class.
C. Run the class in Execute Anonymous and look for coverage in the debug log.Execute Anonymous does not produce coverage data.
D. Open the Test Coverage dashboard in Lightning App Builder.There is no such dashboard in Lightning App Builder.

Why: The Developer Console shows code coverage per class after tests run, in the Overall Code Coverage panel of the Tests tab.

07

A nightly batch job that processes thousands of order records is slow. The developer wants detailed debug logs for specific code and for a particular user. For which three can trace flags be set? Choose 3 answers.

Choose three.

  1. Apex class
  2. Flow
  3. User
  4. Visualforce page
  5. Apex trigger
Show answer

Answer: A, C, E

A. Apex class ✓Correct. Trace flags can target an Apex class.
B. FlowFlows are not a trace flag target.
C. User ✓Correct. Trace flags can target a specific user.
D. Visualforce pageVisualforce pages are not a trace flag target.
E. Apex trigger ✓Correct. Trace flags can target an Apex trigger.

Why: Trace flags can be set on users, Apex classes, and Apex triggers (and on the Automated Process and Platform Integration users).

08

A trigger on Claim__c calls a @future method that sets Review_Status__c on the inserted claims. The test below fails on the assertion because the value is still null. Claim__c c = new Claim__c(Amount__c = 500); insert c; Claim__c result = [SELECT Review_Status__c FROM Claim__c WHERE Id = :c.Id]; Assert.areEqual('Queued', result.Review_Status__c); What should the developer change?

  1. Add @isTest(SeeAllData=true) so the future method can see the record.
  2. Call the future method directly from the test instead of inserting the record.
  3. Wrap the insert in Test.startTest() and Test.stopTest(), then query and assert after Test.stopTest().
  4. Add a loop that waits until Review_Status__c is not null before asserting.
Show answer

Answer: C

A. Add @isTest(SeeAllData=true) so the future method can see the record.SeeAllData controls access to org data; it does not make the asynchronous method run before the assertion.
B. Call the future method directly from the test instead of inserting the record.Calling the method directly skips the trigger, so the test no longer verifies the real behavior.
C. Wrap the insert in Test.startTest() and Test.stopTest(), then query and assert after Test.stopTest(). ✓Correct. Asynchronous Apex started between startTest() and stopTest() runs synchronously when stopTest() is called, so the result can be asserted afterward.
D. Add a loop that waits until Review_Status__c is not null before asserting.Asynchronous jobs do not run while the test method is still executing, so a waiting loop never sees the change and wastes CPU time.

Why: In Apex tests, Test.stopTest() forces all asynchronous work queued after Test.startTest() (future, Queueable, Batch, scheduled) to complete, so assertions should follow it.

09

A test class without SeeAllData=true checks logic that reads configuration and user data. Which two kinds of records can the test query from the org without creating them first? (Choose 2)

  1. Existing Account records
  2. Existing Product2 records
  3. User records
  4. Profile records
  5. Records of a hierarchy custom setting
Show answer

Answer: C, D

A. Existing Account recordsAccount is regular org data and is not visible to tests unless SeeAllData=true is used.
B. Existing Product2 recordsProduct2 records are org data and must be created in the test.
C. User records ✓Correct. User is one of the objects whose records remain visible in tests without SeeAllData=true.
D. Profile records ✓Correct. Profile records are visible in tests, so a test can query a profile to create a test user.
E. Records of a hierarchy custom settingCustom setting data is not visible by default in tests; the test must insert the custom setting records it needs.

Why: Even without SeeAllData, tests can see metadata-like records such as User, Profile, Organization, RecordType, and CronTrigger. Other data, including custom setting records, must be created in the test.

10

A test for a Batch Apex class that archives old Donation__c records inserts 500 donations and calls Database.executeBatch(new DonationArchiver()) inside Test.startTest() and Test.stopTest(). The test fails with an error about the execute method. What is the most likely cause?

  1. Batch Apex classes cannot be tested; their logic must be moved to a helper class.
  2. The test must call the start(), execute(), and finish() methods directly instead of executeBatch().
  3. Database.executeBatch() must be called outside Test.startTest() and Test.stopTest().
  4. A test can run only one execute() call, so the test should insert no more records than the batch size (default 200).
Show answer

Answer: D

A. Batch Apex classes cannot be tested; their logic must be moved to a helper class.Batch Apex can be tested; the test just needs to stay within what a test run allows.
B. The test must call the start(), execute(), and finish() methods directly instead of executeBatch().Calling Database.executeBatch() in the startTest/stopTest block is the standard way to test a batch class.
C. Database.executeBatch() must be called outside Test.startTest() and Test.stopTest().Outside that block, the batch would not complete before the assertions; inside it is correct.
D. A test can run only one execute() call, so the test should insert no more records than the batch size (default 200). ✓Correct. In tests, only one batch of execute() can run, so the number of records must fit in one scope, or a smaller scope must be passed.

Why: When testing Batch Apex, insert at most as many records as the batch size so that execute() runs once, and place Database.executeBatch() between Test.startTest() and Test.stopTest().

11

A test inserts an Order__c record and then calls a method that sends the order to a shipping API using a mocked HTTP callout. The test fails with 'You have uncommitted work pending. Please commit or rollback before calling out.' How should the developer arrange the test?

  1. Insert the Order__c before Test.startTest(), then call the callout method between Test.startTest() and Test.stopTest().
  2. Move Test.setMock() to a @TestSetup method.
  3. Use Database.insert(order, false) so the DML is committed before the callout.
  4. Add @isTest(SeeAllData=true) and use an existing order instead of inserting one.
Show answer

Answer: A

A. Insert the Order__c before Test.startTest(), then call the callout method between Test.startTest() and Test.stopTest(). ✓Correct. Performing the DML before Test.startTest() and the callout after it separates them, so the mock callout can run.
B. Move Test.setMock() to a @TestSetup method.Mocks are not shared from @TestSetup, and moving it does not separate the DML from the callout.
C. Use Database.insert(order, false) so the DML is committed before the callout.allOrNone=false allows partial success; it does not commit the transaction before the callout.
D. Add @isTest(SeeAllData=true) and use an existing order instead of inserting one.Relying on org data makes the test fragile and is not the recommended fix.

Why: Callouts are not allowed after uncommitted DML in the same transaction. In tests, place DML before Test.startTest() and the callout inside the startTest/stopTest block.

12

A developer at a car rental company writes a test for a pricing method that should return 150 for a three-day rental. Which assertion follows the recommended Assert class usage and gives a clear failure message?

  1. System.assert(150, PricingService.quote(3));
  2. Assert.isTrue(PricingService.quote(3), 150);
  3. Assert.areEqual(150, PricingService.quote(3), 'Three-day rental should cost 150');
  4. Assert.fail(PricingService.quote(3) == 150);
Show answer

Answer: C

A. System.assert(150, PricingService.quote(3));System.assert() takes a Boolean condition and an optional message, not an expected and an actual value.
B. Assert.isTrue(PricingService.quote(3), 150);Assert.isTrue() takes a Boolean condition and an optional message; the arguments here do not match.
C. Assert.areEqual(150, PricingService.quote(3), 'Three-day rental should cost 150'); ✓Correct. Assert.areEqual(expected, actual, message) compares the values and shows the message if they differ.
D. Assert.fail(PricingService.quote(3) == 150);Assert.fail() always fails the test with an optional message; it does not evaluate a condition.

Why: The Assert class offers clear methods such as areEqual(expected, actual, msg), areNotEqual, isTrue, isFalse, isNull, isInstanceOfType and fail. Passing the expected value first and a descriptive message makes failures easy to read.

13

A QA team at a healthcare company needs a sandbox with all metadata and a representative sample of production records, selected with a template, for testing a new integration. A full copy of the data is not required. Which sandbox type fits best?

  1. Developer
  2. Developer Pro
  3. Full
  4. Partial Copy
Show answer

Answer: D

A. DeveloperA Developer sandbox copies metadata only and includes no production data.
B. Developer ProA Developer Pro sandbox has more storage than Developer but still copies metadata only, without production records.
C. FullA Full sandbox copies all production data, which is more than needed and has a longer refresh interval.
D. Partial Copy ✓Correct. A Partial Copy sandbox includes all metadata plus a sample of production data chosen with a sandbox template.

Why: Developer and Developer Pro sandboxes contain metadata only. Partial Copy sandboxes add a sample of data defined by a sandbox template, and Full sandboxes copy all data, making them best for performance and staging tests.

14

An Apex trigger on the Payment_Received__e platform event updates the related Invoice__c. The test publishes an event with EventBus.publish() and immediately queries the invoice, but the status has not changed. How should the developer fix the test?

  1. Add @isTest(SeeAllData=true) so the test uses the real event bus.
  2. Query the event object after publishing to force delivery.
  3. Publish the event between Test.startTest() and Test.stopTest(), or call Test.getEventBus().deliver(), before asserting.
  4. Use System.enqueueJob() to publish the event so it runs synchronously.
Show answer

Answer: C

A. Add @isTest(SeeAllData=true) so the test uses the real event bus.SeeAllData controls access to org data; it does not cause test events to be delivered.
B. Query the event object after publishing to force delivery.Platform event messages cannot be queried with SOQL to trigger delivery.
C. Publish the event between Test.startTest() and Test.stopTest(), or call Test.getEventBus().deliver(), before asserting. ✓Correct. In tests, published events are delivered when Test.stopTest() runs or when Test.getEventBus().deliver() is called, which fires the subscriber trigger.
D. Use System.enqueueJob() to publish the event so it runs synchronously.System.enqueueJob() runs Queueable classes; it does not publish or deliver platform events.

Why: In Apex tests, platform event messages are delivered to subscribers after Test.stopTest() or when Test.getEventBus().deliver() is called. Assertions on the subscriber's results must come after delivery.

15

A developer at a logistics startup checks code coverage for the RouteOptimizer class and sees that it is lower than expected. Which statement about how Apex code coverage is calculated is correct?

  1. Lines inside test classes are added to the coverage of the classes they test.
  2. Coverage is calculated per method, so a class is covered when every method is called once.
  3. Comments and blank lines count as uncovered lines, lowering the percentage.
  4. Calls to System.debug() are not counted as part of Apex code coverage.
Show answer

Answer: D

A. Lines inside test classes are added to the coverage of the classes they test.Test classes and test methods are not counted in code coverage calculations.
B. Coverage is calculated per method, so a class is covered when every method is called once.Coverage counts executed lines, not methods; a called method may still have uncovered lines in its branches.
C. Comments and blank lines count as uncovered lines, lowering the percentage.Comments and blank lines are not counted as code lines for coverage.
D. Calls to System.debug() are not counted as part of Apex code coverage. ✓Correct. Salesforce does not count System.debug() statements in coverage, so they neither help nor hurt the percentage.

Why: Apex code coverage is the percentage of executable lines run by tests. Test code, comments, blank lines and System.debug() calls are not counted, so meaningful tests must exercise the real logic and branches.

Find out if you're ready to pass

Take the free Platform Developer diagnostic: 20 questions, no account needed. Then unlock all 300 questions, full practice exams and the study guide.

Start the free diagnosticSee plans

Other sections of this exam