
Serpent Team

Andrew Hanna

Short answer: on every pull request, run only the fast and deterministic checks: static analysis on the diff, LWC Jest, and a validate-only delta deployment that runs just the Apex tests covering the changed code. Push everything slow or flaky, full org test runs, UI journeys and external integrations, to a nightly job. Aim for a pull request verdict in under ten minutes, because past that people stop reading it.
One rule governs this list: everything on the pull request gate must be deterministic. A single flaky test teaches the team to press re-run, and a gate people re-run until it goes green is decoration.
Nightly failures get triaged over coffee. That is the point: they are not standing between a developer and their merge.
Four levels, and the choice per stage is most of the design (Metadata API guide).
NoTestRun: fine inside a scratch org, never on a path to production.
RunSpecifiedTests: your pull request gate. One catch worth knowing: at
this level each class and trigger in the deployment package must reach 75% coverage
individually, computed per component rather than org-wide (Salesforce docs).
RunLocalTests: everything except managed package tests. This is what a
production deployment containing Apex runs by default.
RunAllTestsInOrg: adds managed package tests. Rarely what you want, and
slow.
The platform rules underneath do not change: at least 75% of your Apex must be covered to deploy to production, every trigger needs at least one line of coverage, and every test that executes has to pass, whatever the coverage number says (Salesforce Help).
Not on the pull request. UI tests are the slowest and the most brittle thing in a Salesforce pipeline: shadow DOM in Lightning components, generated element ids and login prompts all break selectors for reasons that have nothing to do with the change under review.
The workable placement is a small smoke set of five to ten critical journeys after merge to the integration branch, and the full suite nightly. A practical rule: if a UI test fails twice for reasons other than the product, it is a maintenance item, not a gate.
This guide is part of our Salesforce DevOps guides.
How fast should a Salesforce pull request check be?
Under ten minutes end to end. Beyond that developers context-switch, stop reading the output, and the check stops changing behaviour.
Should we run all Apex tests on every pull request?
No. Run the tests covering the changed classes with RunSpecifiedTests,
and keep the full local run for the nightly job and the release validation.
What coverage does Salesforce actually require?
75% of Apex org-wide to deploy to production, at least one line of coverage on every
trigger, and every executed test must pass. With RunSpecifiedTests, each
class and trigger in the package needs 75% on its own.
Do LWC Jest tests need a Salesforce org?
No. They run off-platform in Node, which is exactly why they belong on the pull request gate rather than in the nightly job.
Where should UI tests run?
A small smoke set after merge, the full suite nightly. Putting them on the pull request is the fastest way to teach a team to ignore a red build.
Commitment free!