Testing, Debugging, and Deployment20% of the exam

Writing and running Apex and Flow tests

How to structure @IsTest classes, pick a source of test data (@TestSetup, a data factory, Test.loadData, SeeAllData), isolate limits and async work with Test.startTest/stopTest, mock callouts, test triggers and controllers, meet the 75% coverage rule, and test flows with Test Mode or the debugger.

Official exam objective
Write and execute tests for triggers, controllers, classes, and flows using various sources of test data.

~8 min read · 25 practice questions ·

What the exam expects

  • Structure test classes and methods for classes, triggers and Visualforce controllers.
  • Choose a source of test data (records built in the test, @TestSetup, a test data factory, Test.loadData, or SeeAllData=true) and explain data isolation.
  • Use Test.startTest()/Test.stopTest() to isolate governor limits and force asynchronous work (future, Queueable, batch) to finish before assertions.
  • Replace callouts and dependencies with HttpCalloutMock or the Stub API, test as other users with System.runAs(), and prove bulk and negative paths with assertions.
  • State the 75% coverage rule and what counts toward it; test flows with Test Mode or the Flow Builder debugger.

Key terms: test class (a class annotated @IsTest that holds test methods); data isolation (tests see only records they create, by default); test setup method (@TestSetup, builds shared records once per class); mock (a test-only stand-in that returns a canned response); code coverage (executable lines run by tests divided by all executable lines).

Key facts

Default data access
Detail
Only records the test creates, plus setup objects such as User, Profile, RecordType
Class-level SeeAllData=true
Detail
Method-level SeeAllData=false is ignored; records are still rolled back
startTest/stopTest
Detail
Once each per test method; new limits between; async runs at stopTest
Batch Apex in a test
Detail
Only one execution of execute; limit records with the scope parameter
Register a callout mock
Detail
Test.setMock(HttpCalloutMock.class, new MyMock()) before the callout
Stub API can't mock
Detail
Static (including future) and private methods, properties, triggers
System.runAs()
Detail
Enforces the user's sharing and permissions; test methods only
Deployment coverage
Detail
At least 75% of Apex, all tests pass, every trigger has some coverage
Excluded from coverage
Detail
Test classes, comments, blank lines, lone System.debug() lines
Flow Test Mode
Detail
Autolaunched and record-triggered flows; other types use the debugger
Sources for this section (10)
  • Why does a query for records you can see in the sandbox return zero rows inside a test?
  • When does a future method called in a test actually run?
  • Why keep test data builders in an `@IsTest` utility class instead of a plain public class?
  • Which flow types use Test Mode rather than the Flow Builder debugger?
  • What minimum coverage must Apex have before it can be deployed to production?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the Platform Developer pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 21 lessons of the Platform Developer guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (25 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the Platform Developer exam