SALESFORCE-PD1 Testing Debugging And Deployment Practice Question
An Apex trigger performs a callout to an external web service and a developer is writing a unit test for this trigger. How should the developer handle the callout during the test execution?
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
✓
Use Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator())
Apex runtime throws an exception if a callout is attempted in a test without being mocked. The developer must implement the HttpCalloutMock interface and use Test.setMock().
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use System.runAs() to execute the test under a user with API Enabled permissions
Why it's wrong here
API permissions do not bypass the restriction preventing real callouts in tests.
- ✓
Use Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator())
Why this is correct
Test.setMock informs the runtime to return a simulated response instead of making a real callout.
- ✗
Wrap the trigger logic inside a Test.startTest() and Test.stopTest() block without mocks
Why it's wrong here
Start and stop test do not allow actual callouts; mocking is still mandatory.
- ✗
Set the remote site setting dynamically inside the test method before the trigger fires
Why it's wrong here
Remote site settings cannot be modified programmatically via Apex.
About these practice questions
One of 493 original SALESFORCE-PD1 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 August 2026 · checked against the official Salesforce exam blueprint
This SALESFORCE-PD1 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 SALESFORCE-PD1 exam.