Debugging: Apex practice drills
Fix real production bugs: queries and DML in loops, null checks, recursion, mixed DML, empty tests and batch state.
Intermediate · Check and Run with Apex Path ($19 a month).
- Fix a missing null check Beginner · 10 min
Calling a method on a blank field throws Attempt to de-reference a null object.
- Fix a query that finds no rows Beginner · 10 min
Assigning a query to one record throws when nothing matches.
- Fix a query inside a loop Intermediate · 15 min
Too many SOQL queries: 101 is the classic production failure.
- Fix DML inside a loop Intermediate · 15 min
Every insert, update or delete statement counts against the limit of 150 per transaction.
- Fix a test that checks nothing Intermediate · 15 min
A test passes when nothing throws.
- Stop a trigger calling itself Advanced · 15 min
maximum trigger depth exceeded means a trigger caused DML that ran the same trigger, sixteen times.
- Fix a mixed DML error Advanced · 20 min
A User with a role cannot share a transaction with Account.
- Fix a Batch job that forgets its count Advanced · 20 min
Each execute and finish runs in its own transaction on a fresh copy of the class.