SALESFORCE-PD1 Testing Debugging And Deployment Practice Question
Which TWO practices are considered best practices when writing Apex unit tests in Salesforce? (Choose two.)
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
✓
Create all required test data within the test method or test setup method.
Using Test.startTest/stopTest and avoiding SeeAllData=true are essential Apex testing best practices.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Hardcode record IDs directly from the sandbox into assertions.
Why it's wrong here
Hardcoding record IDs causes tests to fail when deployed to other environments where IDs differ.
- ✓
Create all required test data within the test method or test setup method.
Why this is correct
Creating test data locally ensures test independence and reliability.
- ✗
Query production records directly in every assertion to verify live system status.
Why it's wrong here
Unit tests should not rely on live production data querying.
- ✓
Use Test.startTest() and Test.stopTest() to isolate governor limits for the code being tested.
Why this is correct
Isolating limits with startTest and stopTest is a core best practice.
- ✗
Use @isTest(SeeAllData=true) on all test classes to ensure maximum compatibility with production data.
Why it's wrong here
SeeAllData=true should be avoided unless strictly necessary to prevent dependency on brittle production state.
About these practice questions
One of 488 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.