Exam PDII Topic 2 Question 66 Discussion

Actual exam question for Salesforce's PDII exam
Question #: 66
Topic #: 2
A developer created 2 class that implements the Queueable Interface, as follows:

As part of the deployment process, the developer is asked to create a corresponding test class.
Which two actions should the developer take to successfully execute the test class?
Choose 2 answers

Suggested Answer: C,D Vote an answer

When writing a test class for a Queueable class in Salesforce, the goal is to ensure that the asynchronous code is executed within the test context and that it does not affect the state of the production org or depend on its data.
* Option C is correct because using Test.startTest() and Test.stopTest() ensures that the asynchronous code is executed immediately within the test's context. This is essential for testing Queueable classes because it allows the test to wait for the asynchronous process to complete before assertions are made.
Without this, the asynchronous job would not necessarily run during the test execution.
* Option D is correct because Test.isRunningTest() can be used within the Queueable class to prevent the chaining of jobs during test execution. Chaining queueable jobs can lead to governor limits being hit and is generally not allowed in test methods. This conditional check allows the developer to bypass sections of the code not suitable for a testing context.
* Option A is incorrect because the seeAllData=True annotation is not required for testing Queueable classes, and it is not a best practice to depend on live data for tests. It's preferable to create test data within the test class itself.
* Option B is incorrect because having the 'View All' permission on the Order object is not related to the successful execution of the Queueable class in tests. Permissions are typically not enforced in test contexts unless using System.runAs() to test with a specific user context.
References:
Salesforce Documentation on Queueable Apex: Queueable Apex
Salesforce Documentation on Testing Asynchronous Apex: Testing Asynchronous Apex

by Merlin at Jun 10, 2026, 11:18 PM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10