Courseiva

SF-PD2 Process Automation, Logic, and Integration Practice Question

A developer is writing a test class for a service that performs a callout to an external web service. The developer needs to mock the callout response to test different scenarios without making actual HTTP requests. Which interface should the developer implement to mock the callout?

⚠ Common exam trap

It's easy for candidates to confuse WebServiceMock for HTTP callout mocking, or inventing an interface like System.HttpMock, when the correct one is HttpCalloutMock.

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

✓

HttpCalloutMock

The HttpCalloutMock interface is the correct choice for mocking HTTP callouts in Apex tests. It allows developers to define custom responses for callouts, enabling comprehensive testing without external dependencies. WebServiceMock is for SOAP services, Database.AllowsCallouts is for enabling callouts in asynchronous Apex, and System.HttpMock is not a valid interface.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Database.AllowsCallouts

    Why it's wrong here

    Database.AllowsCallouts is an interface that allows asynchronous Apex (like Queueable or Batch) to make callouts. It does not mock callouts. Implementing it in a test class would not help simulate responses; it is used in production code to enable callouts in asynchronous contexts.

  • ✗

    WebServiceMock

    Why it's wrong here

    WebServiceMock is used to mock SOAP-based web service callouts made with the generated Apex classes from WSDL. It is not used for HTTP callouts made with HttpRequest and Http classes. The scenario describes a generic callout to an external web service, likely REST, so WebServiceMock is not appropriate.

  • ✗

    System.HttpMock

    Why it's wrong here

    System.HttpMock does not exist as an interface. The correct interface is HttpCalloutMock, which is part of the System namespace but not named System.HttpMock. This option is a fabricated name that sounds plausible but is not a real Salesforce interface. Developers should use HttpCalloutMock.

  • ✓

    HttpCalloutMock

    Why this is correct

    The HttpCalloutMock interface is specifically designed to mock HTTP callouts in Apex tests. By implementing this interface and its respond method, developers can return a fabricated HttpResponse without making a real callout. This allows testing of various response scenarios, including success and error cases, and is the standard approach for callout testing.

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.