How to mock HTTP callouts in Apex tests
— Test.setMock and the one-method HttpCalloutMock interface, a configurable mock for the suite, a router mock for multi-callout flows, and the uncommitted-work gotcha — plus why the failure-response matrix is the part worth testing.
Apex CPU time limit exceeded — find the hotspot, fix the shape
— The 10-second budget is shared by your Apex, your Flows, and managed packages — but not database time. The usual culprits (nested loops, recursion, describes in loops), Limits.getCpuTime() checkpoints, and the 200-record budget test.
Testing async Apex — Queueable, Batchable, Scheduled, and @future
— Async work runs at Test.stopTest, not when you call it. The per-flavor playbook: one batch scope of data, the Test.isRunningTest() chain guard, testing a schedulable's execute directly, and asserting on AsyncApexJob.
SeeAllData is a debt — test data factories in Apex
— Tests that read org data fail everywhere except the org they were written against. The factory pattern that absorbs schema churn in one file, @testSetup snapshots, and why fast local runs remove the incentive that creates SeeAllData.
Running Apex tests with the sf CLI — the complete workflow, and where the time goes
— Every sf apex run test flag that matters, the async queue and --wait, recovering results with sf apex get test — and an honest accounting of why the slow part is never the CLI itself.
The scratch org tax — what org setup really costs, and which parts you can stop paying
— Create, deploy, permsets, seed data, expiry, Dev Hub allocations — the full scratch org lifecycle priced honestly, and why the highest-frequency org use (the Apex test loop) is the easiest to take off the org.
Debugging Apex with debug logs — the workflow, the limits, and the way out
— Trace flags, log levels, sf apex tail log, and reading a FINEST log without losing the afternoon — plus why it's print-statement debugging with extra steps, and what breakpoints in Apex look like instead.
Too many SOQL queries: 101 — find the loop, fix the pattern
— The error is rarely about the limit — it's a query running per record, usually in a trigger under bulk load. How to find the loop, the collect-query-map fix, and the 200-record test that keeps it fixed.
Detect the Nimbus runtime from Apex
— A one-line isNimbus() helper using standard SOQL on Organization.InstanceName tells your Apex whether it is running locally or in a real org — and you can set the instance name yourself in nimbus.properties.
Design Salesforce like a distributed system
— Bounded contexts, event-driven architecture, platform events as facts not commands, and the Trigger Actions framework — the discipline network boundaries enforce for free, plus how to test every cross-domain contract locally without an org.
The hidden cost of the Apex feedback loop
— Deploy, wait, run tests, wait, switch back. The real cost of the Apex loop — measured in hours, focus, and the designs it quietly discourages.
75% code coverage is a deployment gate, not a test strategy
— Salesforce requires 75% Apex code coverage to deploy. That number says almost nothing about whether your code works. What coverage measures, and what to measure instead.
The Apex inner loop in VS Code — run, test, and debug without an org
— How to run Apex tests, step through a live debugger, and watch coverage in VS Code — with no scratch org, no sandbox, and no deploy step between you and a result.
What Test.startTest and Test.stopTest actually do
— Two jobs: a fresh set of governor limits for the code under test, and synchronous execution of async work at stopTest. Everything about where to arrange, act, and assert follows from those two.
Do you still need an Apex trigger framework?
— Ordering, bypass, recursion — the three problems a trigger framework actually solves, why a ~40-line handler covers most teams, and when metadata-driven frameworks earn their weight.