Courseiva

SF-PD2 Testing, Debugging, and Deployment Practice Question

A 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.)

⚠ Common exam trap

The trap here is believing that Test.isRunningTest() branching is the proper way to avoid callouts, when mocking the HTTP transport is the supported technique.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Implement HttpCalloutMock and register it with Test.setMock(HttpCalloutMock.class, mock) before invoking the Queueable.

To test a Queueable that makes a callout and chains another job without real external calls, the developer registers an HttpCalloutMock so the callout is stubbed, and wraps the enqueue in Test.startTest()/Test.stopTest() so queued work runs synchronously. Together these techniques validate both the callout handling and the chained job's behavior in a controlled, offline test.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Annotate the test method with @IsTest(SeeAllData=true) so the chained job can see the records it needs.

    Why it's wrong here

    SeeAllData=true only exposes pre-existing org data to the test; it does not affect asynchronous execution or callout handling. It would not make the chained Queueable run, and relying on live data makes the test fragile. It is not one of the two required techniques for this scenario.

  • ✗

    Set the Queueable to run with System.enqueueJob(new MyQueueable(), 5) to increase the delay so the test can observe intermediate state.

    Why it's wrong here

    The delay parameter in enqueueJob affects when the job starts in production, but inside a test the job runs when Test.stopTest() is called regardless of the delay. Adding a delay does not help the test observe intermediate state and is unrelated to mocking the callout.

  • ✗

    Replace the callout with a hard-coded response inside the Queueable when Test.isRunningTest() returns true.

    Why it's wrong here

    Bypassing the callout with a Test.isRunningTest() branch means the production callout logic is never exercised, so the test would not validate the actual code path. The HttpCalloutMock approach is preferred because it tests the real callout code against a stubbed response.

  • ✓

    Implement HttpCalloutMock and register it with Test.setMock(HttpCalloutMock.class, mock) before invoking the Queueable.

    Why this is correct

    Registering an HttpCalloutMock replaces the real HTTP transport with the mock during the test, so the Queueable's callout returns the stubbed response without leaving the Salesforce servers. This is the standard mechanism for testing callout logic offline and keeps the test deterministic and fast.

  • ✓

    Call Test.startTest() before enqueueing the job and Test.stopTest() after, so the asynchronous work executes synchronously.

    Why this is correct

    Test.startTest() and Test.stopTest() bound the asynchronous work and force queued jobs to run before stopTest returns. Wrapping the enqueue calls this way ensures the Queueable and its chained job actually execute during the test, allowing assertions on their results.

About these practice questions

This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Salesforce exam blueprint

This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.