PD1 Testing, Debugging & Deployment 5 — Questions and Answers
Question 1: What is the role of the @isTest annotation in Apex?
- It publishes the class to the AppExchange
- It marks a class or method as a test that does not count toward org code limits (Correct answer)
- It enables debug logging for the class
- It prevents the class from being deployed to production
Correct answer: It marks a class or method as a test that does not count toward org code limits
@isTest designates Apex code as test-only, excluding it from production code limits and preventing it from being called in non-test contexts.
Question 2: Which Salesforce tool lets you inspect the heap size, execution time, and line-by-line code path during an Apex debug session?
- Log Inspector in Developer Console (Correct answer)
- Apex Debugger in VS Code
- Workbench REST Explorer
- Setup > Apex Classes
Correct answer: Log Inspector in Developer Console
The Developer Console's Log Inspector provides an execution overview, heap view, and timeline for analyzing debug logs.
Question 3: When writing a test for a batch Apex class, which method must you call to actually execute the batch logic synchronously within the test?
- Database.executeBatch() (Correct answer)
- Test.runBatch()
- Batch.execute()
- System.scheduleBatch()
Correct answer: Database.executeBatch()
Database.executeBatch() is used inside Test.startTest()/Test.stopTest() to enqueue the batch, and Test.stopTest() forces synchronous execution.
Question 4: Which sandbox type can be refreshed most frequently — once every 1 day?
- Full Sandbox
- Partial Copy Sandbox
- Developer Sandbox (Correct answer)
- Developer Pro Sandbox
Correct answer: Developer Sandbox
Developer Sandboxes have a 1-day refresh interval, the shortest of all sandbox types, supporting rapid iteration.
Question 5: What does it mean when a deployment fails due to 'missing test coverage' for a specific Apex class?
- The class has no comments
- Less than 75% of the class's lines are executed by any test in the org (Correct answer)
- The class has no @isTest methods inside it
- The class was not included in the change set
Correct answer: Less than 75% of the class's lines are executed by any test in the org
Each Apex class (excluding test classes) must have at least 75% of its executable lines covered by test methods in the org.
Question 6: Which Salesforce CLI command retrieves metadata from an org into your local project in source format?
- sf project retrieve start (Correct answer)
- sf org pull metadata
- sf source retrieve
- sf metadata download
Correct answer: sf project retrieve start
sf project retrieve start (formerly sfdx force:source:retrieve) pulls metadata from the org and converts it to source format locally.
Question 7: What is the primary advantage of using scratch orgs over developer sandboxes for development?
- Scratch orgs include a copy of production data
- Scratch orgs can be scripted, versioned, and created on-demand for CI/CD (Correct answer)
- Scratch orgs have no governor limits
- Scratch orgs persist indefinitely without expiry
Correct answer: Scratch orgs can be scripted, versioned, and created on-demand for CI/CD
Scratch orgs are disposable, source-driven environments that can be created via CLI scripts, making them ideal for automated CI/CD pipelines.
What is the role of the @isTest annotation in Apex?