The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Must-read

Where the Metadata API deployment result keeps its errors and coverage warnings (opens in a new tab)

You will know which fields of the deployment result hold component errors, test failures and coverage warnings, and why a deployment can fail with an empty componentFailures list.

Why read this

The post also gives a checklist for diagnosing a failed deployment.

  1. Set includeDetails to true
  2. Check componentFailures
  3. Check runTestResult failures
  4. Check runTestResult codeCoverageWarnings
Where to look when a deployment fails with no component errors

A failed Metadata API deployment often reports no component errors because the cause sits in another part of the result. The post explains the result layout, using Salesforce’s documentation. The overall outcome is in the DeployResult returned by checkDeployStatus(), but the detail is in its details field, which is only populated when includeDetails is set to true.

The details hold componentFailures and componentSuccesses, each a list of DeployMessage entries, plus runTestResult and retrieveResult where applicable. Each DeployMessage is typed as Warning or Error, a distinction that did not exist before API version 18.0, when every problem stopped the deployment. While a deployment is running, only componentFailures is filled in; the other fields appear after it finishes, so a mid-run check can show failures with no test results yet.

Test-side problems sit one level further down, in runTestResult. Failing tests are listed in its failures, and coverage problems in codeCoverageWarnings. A deployment can therefore fail with componentFailures empty and no test failing, for example when a class is not covered under a RunSpecifiedTests run. The post closes with a checklist: confirm includeDetails was set, check componentFailures, then check runTestResult failures and coverage warnings, make sure the deployment has finished, and compare the package’s classes with the classes the named tests cover.

The post also notes that the component lists moved from the deployment result into details, a change Salesforce says took effect in API version 29.0, so older scripts may look in the wrong place.

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

Worth reading?

Recommended

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?

Choosing between Custom Metadata Types and Custom Settings for org configuration (opens in a new tab)

You will learn which configuration store fits deployment-time values, which fits per-user or runtime state, and how to migrate between them.

Why read this

The article gives a clear decision rule that you can apply when designing new configuration.

Custom Settings

  • Records are data, not metadata
  • Not in change sets or packages
  • Hierarchy cascade: org, profile, user
  • Count against data storage

Custom Metadata Types

  • Stored as metadata
  • Deploy with change sets and packages
  • Referenced from formulas and Flows
  • Apex cannot edit them at runtime
Custom Settings and Custom Metadata Types differ in how they deploy and in what they can do at runtime

Salesforce orgs need to store configuration that code reads, such as feature flags, endpoint URLs and thresholds. The article contrasts the two classic options, Custom Settings and Custom Metadata Types, and notes that choosing the wrong one tends to cause problems later, often during deployment.

Custom Settings hold org-specific data in two forms: List settings, which are sets of records, and Hierarchy settings, which cascade values from org to profile to user. The cascade is their main advantage, since it allows per-user or per-profile values without code. Their records are data rather than metadata, so they do not travel with change sets or packages, must be recreated in each sandbox and in production, are invisible to the Metadata API, and count against data storage.

Custom Metadata Types store configuration as metadata that deploys with change sets, unlocked packages and the Metadata API. They can be referenced from formulas, Flows, Apex and Validation Rules, and they support protected records in managed packages. Their limits are that Apex cannot create or edit them at runtime, and they have no per-user or per-profile cascade, so one value applies to everyone in the org.

The article’s rule is to ask whether the value changes at runtime or only at deployment. Runtime state such as counters or timestamps belongs in Custom Settings or a Custom Object, while deployment-time configuration belongs in Custom Metadata Types. Per-user or per-profile values call for Hierarchy Custom Settings. Many orgs combine both, using Custom Metadata Types for stable configuration and a Custom Setting or Custom Object for live state.

For migration, the author recommends creating the Custom Metadata Type with the same fields, recreating the records as metadata, and updating references, noting that the getInstance() call changes to the mdt syntax. Migrate one setting at a time, keep the old one until the new one is proven, and check that test classes still cover the code so the 75% deployment gate is not breached.

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

Worth reading?

Recommended

Running Apex tests on a local runtime, without an Org round trip (opens in a new tab)

You will learn what renmy runtime does, how it runs Apex and Flows locally against an embedded PostgreSQL, and which commands cover testing, debugging, AI agent integration and gated deploys.

Why read this

You will also see what the benchmark claims and what sits behind the Pro tier.

  1. Snapshot selected source into a bundle
  2. Run local validation and test gates
  3. Check-only validation in the target org
  4. Deploy the validated bundle
The gated deploy path from local source to the Salesforce org

Nimbus has been renamed renmy runtime, with the same tool and the same binary. It is a local Salesforce Apex runtime that executes real Apex, SOQL, DML and Salesforce Flows on a developer’s machine against an embedded PostgreSQL database. The runtime enforces platform rules such as governor limits, order of execution across triggers and flows, and per-test transaction isolation. It ships as a single binary for macOS, Linux and Windows and needs no org, Scratch Org, Docker or JVM.

The article’s benchmark compares four open-source Apex suites containing 837 tests. Run in a Salesforce org, they took about 1 minute 46 seconds, and locally they took about 2.4 seconds, roughly 45 times faster, with every test passing in both places. Around the runtime sit a language server that serves editors such as VS Code, Cursor, Neovim, Zed and JetBrains IDEs, a live debugger that supports breakpoints and stepping, and line and branch coverage reporting. Pro adds mutation testing, which the author says is the first of its kind for Apex, and watch mode. The toolkit also includes failure explanation and triage tools, a browser-based Dev UI, and a flaky-test finder.

For AI coding agents, renmy provides an MCP server with tools for running tests, executing anonymous Apex, reading coverage and explaining failures, so agents can verify Apex locally before anything reaches an org. The deployment path is gated: renmy deploy is free and snapshots the source, runs local tests and coverage gates, validates the same bytes in the target org with a check-only validation, and then deploys. The Pro renmy release commands split validation from deployment and produce a receipt that records the bundle digest, Git revision, gate results and the validation job ID, so a team can approve and deploy the validated payload from another machine. The article stresses that Sandboxes remain useful for end-to-end checks and user-facing testing.

The Free tier costs nothing without a card and covers unlimited local test runs, gated deploys, Salesforce CLI pass-through and IDE integrations on one machine. Pro, which adds the daemon, parallel runs, debugger stepping, mutation testing and the MCP server across three machines, and Team are both free during the public beta. Their list prices are $19 per month and $49 per developer per month, and Enterprise starts at $20,000 per year.

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

Worth reading?