Courseiva

SF-PD2 Testing, Debugging, and Deployment Practice Question

An 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?

⚠ Common exam trap

The trap here is believing a governor-limit boundary or an annotation can authorize real callouts in a test, when the platform requires an injected mock instead.

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() before the code under test invokes the callout.

Apex tests are isolated from external systems, so any callout must be replaced with a mock. Implementing HttpCalloutMock and registering it via Test.setMock() lets the code under test receive a controlled response, allowing the developer to assert on parsing, status handling, and error branches without a live service.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Wrap the callout in Test.startTest() and Test.stopTest() so the platform permits external requests.

    Why it's wrong here

    startTest and stopTest bracket the code that should receive a fresh set of governor limits; they do not grant permission to make real callouts. The platform still blocks the external request inside a test transaction. The error would persist because the underlying restriction is about callouts in tests, not about limit boundaries.

  • ✗

    Add the @future(callout=true) annotation to the method performing the callout.

    Why it's wrong here

    The callout=true parameter on @future allows a future method to make callouts in production, but it does not lift the test restriction on Web service callouts. The test would still throw the same error because the platform blocks real callouts in test context regardless of the annotation. This changes production behavior, not test behavior.

  • ✗

    Grant the running user the 'Make Callouts in Tests' permission in the test class profile.

    Why it's wrong here

    No such permission exists on profiles or permission sets. The platform enforces the no-callouts-in-tests rule at the runtime level, not through user permissions. Attempting to configure a permission would fail because the setting is not available, and the test would continue to error.

  • ✓

    Implement HttpCalloutMock and register it with Test.setMock() before the code under test invokes the callout.

    Why this is correct

    Apex tests cannot perform real HTTP callouts, so the platform requires a mock. Implementing HttpCalloutMock and registering it with Test.setMock(HttpCalloutMock.class, mock) causes the callout to return the canned response, letting the test verify parsing and error handling deterministically without network access.

About these practice questions

One of 226 original SF-PD2 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.