Today4 stories · 1 brief

The Daily Org

Spring '27Sandboxes 6 Feb 2027

Curated by Abhinav (opens in a new tab)

Vol. I · No. 55The independent daily for Salesforce admins, developers and architects4 stories · 1 brief

Must-readDevOps

When Salesforce runs Apex tests on a deployment, and how to run fewer (opens in a new tab)

You will learn which test levels Salesforce applies by default, the coverage rules that constrain RunSpecifiedTests, and five practical ways to shorten production deployments.

Why read this

The post also flags that one Flow-related default is not yet verified in production.

  1. Check whether the package contains Apex or Flows
  2. Pick a test level or accept the default
  3. Apply the 75% coverage rule
  4. Quick deploy a validated package
How Salesforce decides which Apex tests to run on a production deployment

Apex tests are usually the slowest part of a Salesforce deployment to production. The article lists the test levels the Salesforce CLI offers: NoTestRun, RunSpecifiedTests, RunLocalTests, RunAllTestsInOrg and RunRelevantTests, the last still in beta. When no level is chosen, the default depends on the target: sandboxes and Developer Edition orgs run no tests, while production runs all local tests if the package contains Apex classes or triggers. The author notes that Flows set to activate on deployment also count, which is a common cause of unexpectedly slow deployments.

The coverage rules decide whether a production deployment can pass. With RunLocalTests or RunAllTestsInOrg, the org needs at least 75% Apex coverage overall and every test that runs must pass. With RunSpecifiedTests, each Apex class and trigger in the package needs 75% coverage on its own from the named tests, so a class with no selected test fails even when a full run would have passed.

The article gives five ways to run fewer tests: keep unchanged Apex out of the package, deploy only the differences from the target, specify tests while checking per-class coverage, consider RunRelevantTests with its beta limits in mind, and validate ahead then quick deploy within 10 days. It also suggests shipping configuration separately from code, since a package with no Apex needs no tests at the default level. The author tested check-only deployments against a Developer Edition org only, so the Flow default has not been confirmed in production. The post closes by describing how the Diffbridge tool’s Smart test level automates these choices.

Read the original at dev.to (opens in a new tab)

Worth reading?

RecommendedDevOps

Why RunSpecifiedTests fails on a class RunLocalTests passes (opens in a new tab)

You will learn how RunLocalTests and RunSpecifiedTests apply different per-class coverage rules, why a specified run can fail at 0% coverage, and where the coverage warning appears in Metadata API results.

RunLocalTests

  • Runs all local tests
  • Overall coverage of at least 75%
  • Coverage counted from all tests that ran

RunSpecifiedTests

  • Runs only the named tests
  • Each class at least 75% individually
  • Coverage counted from named tests only
RunLocalTests and RunSpecifiedTests apply different coverage rules

Salesforce production deployments are usually validated at one of two test levels, RunLocalTests and RunSpecifiedTests. RunLocalTests runs every test in the org except those from installed managed and unlocked packages, and it is the default when the package contains Apex classes or triggers. RunSpecifiedTests runs only the tests named in the runTests option.

The two levels count coverage differently. RunLocalTests requires overall org coverage of at least 75 percent, so a weak class can pass if the rest of the org is well covered. RunSpecifiedTests requires each Apex class and trigger in the package to reach 75 percent individually, and only the named tests count toward that figure. A class covered by none of the named tests therefore fails the deployment even when a full local run would have passed.

The article gives a hypothetical package of 13 components with three Apex classes, where two named tests cover two of them and the third sits at 0 percent. Two fixes are offered: add a test that covers the class, or remove the class from the package if it has not changed. Coverage failures are reported under details.runTestResult.codeCoverageWarnings in the checkDeployStatus() result, which appears only when includeDetails is true, so tooling that prints just the error lists can make such a failure look unexplained.

The author suggests RunLocalTests when the simplest and safest run matters more than time, or when it is unclear which tests cover which classes. RunSpecifiedTests suits teams that know the covering tests for every class and want a shorter run. The piece also notes that RunRelevantTests is in beta and should be checked against current documentation, and that NoTestRun applies only to development environments, not production. The Salesforce CLI exposes these choices through –test-level and –tests. The article closes with a note on the author’s own tool, Diffbridge.

Read the original at dev.to (opens in a new tab)

Worth reading?

DevOps

Validate ahead of the release window, then quick deploy without re-running tests (opens in a new tab)

You will learn what conditions a validation must meet to be promoted by quick deploy, including the 10-day limit and coverage rules, and how to structure a release around it.

Why read this

You will also see a CLI caveat about validating packages with no tests.

  1. Validate ahead of the window against the target
  2. Check the validation passed and note its ID
  3. Quick deploy that ID inside the window
  4. Validate again if the package or target changes
The validate-then-quick-deploy workflow for a release window

Production deployments that run Apex tests are slow, and the release window is short. Salesforce lets you run a deployment as a validation, also called a check-only deployment, which runs everything a real deployment would, tests included, but saves nothing in the org. If the validation passes, you can later promote it with a quick deploy, which deploys the validated components without running the Apex tests again. The Metadata API calls this deployRecentValidation(), the Salesforce UI offers it on the Deployment Status page, and the CLI uses sf project deploy validate followed by sf project deploy quick.

Salesforce sets several conditions. The components must have validated successfully for the target environment within the last 10 days, and the Apex tests in the target org must have passed as part of that validation. Code coverage must also be met: with all tests or all local tests, overall coverage must be at least 75% and Apex triggers must have some coverage; with RunSpecifiedTests, each deployed class and trigger must be at least 75% covered individually. Salesforce says a validation with passing tests only sometimes qualifies, so the author advises confirming it rather than assuming. Trailhead’s guidance adds that you should not deploy again or make major changes to the org in between.

Two consequences follow. A validation without tests cannot be promoted this way, because the quick deploy skips tests that the validation already ran, so there is nothing to skip. The tests chosen at validation time are the tests you get, and a quick deploy does not add or change them. If the per-class coverage rule fails under RunSpecifiedTests, the quick deploy is unavailable, so it is better to discover that during validation than inside the window. The suggested workflow is to validate ahead of the window against the same target with the test level you will rely on, check that it passed, note its ID, then quick deploy that ID inside the window. If the package or target changes, validate again. The 10-day limit is the main thing to watch, since a validation run before a long weekend may have expired.

The author also reports that sf project deploy validate rejected –test-level NoTestRun in their CLI run. To check a package with no tests, sf project deploy start –dry-run –test-level NoTestRun performs a check-only deployment, but nothing can be quick deployed afterwards. Some Stack Exchange answers report that a CLI –dry-run is not treated as a validation by sf project deploy quick, so use sf project deploy validate when planning a quick deploy and check this against your CLI version.

Read the original at dev.to (opens in a new tab)

Worth reading?

DevOps

How CI should handle stale pushes queued behind a Salesforce deployment (opens in a new tab)

You will learn the three policies for dealing with superseded pushes while a Salesforce deployment is running, and the condition that decides which are safe.

Why read this

You will also see why cancelling a deployment is only a request to Salesforce.

State-based jobs

  • Compare the whole branch with the org
  • Skipping a push is safe
  • The sha is only a label

Delta-style jobs

  • Deploy only one push's files
  • Skipping a push drops its changes
  • Safe only if bundled into the next run
State-based and delta-style jobs respond differently when a push is skipped

Salesforce allows one deployment per org at a time, and a deployment with tests can take a long time. When new commits arrive during a running deployment, a pipeline that runs every job in order can spend most of its time deploying changes that a later push already contains. The article uses a 25-minute deployment and three pushes as its example, and notes that the third push would go live an hour after it was made.

The article sets out three policies. Running every job keeps a record of each merge and suits production deployments. Skipping stale waiting jobs drops the middle push but lets the running job finish, which suits busy orgs. Latest wins cancels the running job and drops the waiting ones, which suits validations on pull request or integration branches where only the newest commit matters.

The deciding condition is whether each job deploys the whole branch or only the files changed in one push. State-based jobs compare the whole branch with the org, so skipping an intermediate push is safe. Delta-style jobs deploy only one push’s changes, so skipping one would drop them unless the tool bundles them into the next run. The article also warns that cancelling is a request to Salesforce, not an instant stop, and that a small deployment can finish before the cancel arrives. Building this with GitHub Actions concurrency stops the workflow but not a deployment already submitted to Salesforce, so the script must send the cancel and wait for confirmation.

The article closes with rules for any pipeline: supersede only within the same source, handle validations and deployments separately, never supersede a rollback, and provide a way to move an urgent job to the front. Its suggested default is latest wins for validations and run every job for production deployments. The piece is written by the author of Diffbridge and includes a description of how that tool implements these options.

Read the original at dev.to (opens in a new tab)

Worth reading?

In brief