SF-PD2 Testing, Debugging, and Deployment Practice Question
A developer is writing a test class for a service that makes callouts to an external web service. The test method needs to simulate the callout response without making an actual HTTP request. (Choose two.)
⚠ Common exam trap
The trap here is assuming that Test.startTest or SeeAllData can simulate callouts, when only mock interfaces can intercept callouts.
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 the HttpCalloutMock interface and use Test.setMock(HttpCalloutMock.class, mock).
To simulate callouts in Apex tests, developers can use HttpCalloutMock for HTTP callouts or WebServiceMock for SOAP callouts. Both require implementing the respective interface and registering the mock with Test.setMock. This intercepts the callout and returns a controlled response. Test.startTest and Test.stopTest do not simulate callouts, and SeeAllData does not affect callouts.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Implement the HttpCalloutMock interface and use Test.setMock(HttpCalloutMock.class, mock).
Why this is correct
Implementing HttpCalloutMock allows you to define a fake response. Test.setMock registers the mock for the test, so callouts are intercepted. This is the standard way to test callouts. It ensures no actual HTTP request is made and the response is controlled. This is a correct technique.
- ✗
Use @isTest(SeeAllData=true) to access external data.
Why it's wrong here
@isTest(SeeAllData=true) grants access to org data, not external web service data. It does not affect callouts. It is used for data access in tests, not for simulating HTTP responses. This option is irrelevant to the scenario and would not help simulate a callout.
- ✗
Use Test.startTest() and Test.stopTest() to isolate the callout.
Why it's wrong here
Test.startTest() and Test.stopTest() are used to reset governor limits and to execute asynchronous processes, but they do not simulate callouts. They do not prevent actual callouts from being made. Without a mock, the test would fail with a callout exception. So this is not a valid technique for simulating callout responses.
- ✗
Set the callout to run asynchronously to avoid the callout limit.
Why it's wrong here
Running callouts asynchronously does not simulate the response; it still makes a real callout. Test methods cannot make actual callouts unless a mock is set. Asynchronous execution does not bypass the need for a mock. This option is incorrect because it does not simulate the response and would still fail.
- ✓
Use Test.setMock(WebServiceMock.class, mock) with a WebServiceMock implementation.
Why this is correct
WebServiceMock is used for testing SOAP callouts generated from WSDL. It allows you to simulate the response. Test.setMock registers the mock. This is another correct way to simulate callouts, specifically for SOAP-based services. It is valid and distinct from HttpCalloutMock.
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 →
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.