<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Diffbridge Blog]]></title><description><![CDATA[Diffbridge Blog]]></description><link>https://diffbridge.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6b0ad37f1ff8e7ec687795a4/1de46382-ce30-450e-b786-e18197b483ef.png</url><title>Diffbridge Blog</title><link>https://diffbridge.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 22:10:57 GMT</lastBuildDate><atom:link href="https://diffbridge.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Salesforce deployment failed with no errors? Where the result keeps them]]></title><description><![CDATA["The deployment failed and there are no errors" is a common complaint. It usually means the failure is in a part of the result that the tool didn't print…]]></description><link>https://diffbridge.hashnode.dev/salesforce-deployment-failed-with-no-errors-where-the-result-keeps-them</link><guid isPermaLink="true">https://diffbridge.hashnode.dev/salesforce-deployment-failed-with-no-errors-where-the-result-keeps-them</guid><category><![CDATA[Salesforce]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Apex]]></category><category><![CDATA[api]]></category><dc:creator><![CDATA[Diffbridge]]></dc:creator><pubDate>Sun, 29 Nov 2026 14:34:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0ad37f1ff8e7ec687795a4/24f375d3-2acc-4f2c-b7a4-4071064629d7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>"The deployment failed and there are no errors" is a common complaint. It usually means the failure is in a part of the result that the tool didn't print. This post maps where a Metadata API deployment keeps its errors, its test failures and its coverage warnings, using Salesforce's documentation of the deployment result.</p>
<img src="https://diffbridge.com/blog-images/deployment-result-map.webp" alt="Map of a deployment result: DeployResult, then details, then DeployDetails with componentFailures, componentSuccesses, runTestResult and retrieveResult, and codeCoverageWarnings inside runTestResult" style="display:block;margin:0 auto" />

<h2>The result object</h2>
<p>You start a deployment with <code>deploy()</code>. To follow it, you call <code>checkDeployStatus()</code> in a loop. It returns a <code>DeployResult</code>, and you check its <code>done</code> field to see whether the deployment has finished.</p>
<p>The <code>DeployResult</code> has the overall outcome. The detail is in its <code>details</code> field, and that field is empty unless you ask for it: <code>details</code> is only returned if you set <code>includeDetails</code> to true in the <code>checkDeployStatus()</code> call. A script that never sets it sees the summary and none of the lists below.</p>
<h2>What is inside the details</h2>
<p><code>details</code> holds a <code>DeployDetails</code> entry. These are the parts that matter:</p>
<table>
<thead>
<tr>
<th>Part</th>
<th>What it holds</th>
</tr>
</thead>
<tbody><tr>
<td><code>componentFailures</code></td>
<td>One <code>DeployMessage</code> per component that failed, with the file name, the line number and the problem description</td>
</tr>
<tr>
<td><code>componentSuccesses</code></td>
<td>One <code>DeployMessage</code> per component that deployed</td>
</tr>
<tr>
<td><code>runTestResult</code></td>
<td>The Apex test results, when tests ran as part of the deployment</td>
</tr>
<tr>
<td><code>retrieveResult</code></td>
<td>The retrieve result, only if you asked for a retrieve alongside the deploy</td>
</tr>
</tbody></table>
<p>Each <code>DeployMessage</code> has a problem type of either <strong>Warning</strong> or <strong>Error</strong>. Salesforce notes that before API version 18.0 there was no such distinction, and every problem was treated as an error that stopped the deployment.</p>
<h2>Timing: what you see while it runs</h2>
<p>While a deployment is still in progress, <code>DeployDetails</code> contains only <code>componentFailures</code>. The other fields fill in after the deployment finishes. So a status check made mid-run can show failures but no test results yet, and that is expected.</p>
<h2>Tests live one level further down</h2>
<p><code>runTestResult</code> is a <code>RunTestsResult</code>, and that is where the test side of a failure sits:</p>
<ul>
<li><strong>Failing tests</strong> are listed in its <code>failures</code>.</li>
<li><strong>Coverage problems</strong> are listed in its <code>codeCoverageWarnings</code>, an array of coverage warnings.</li>
</ul>
<p>This is why a deployment can fail while <code>componentFailures</code> is empty and no test failed. If the coverage rule wasn't met, for example a class in a <code>RunSpecifiedTests</code> run that none of the named tests covered, the evidence is in <code>runTestResult.codeCoverageWarnings</code>, not in the component errors or the test failures.</p>
<h2>A checklist for "it failed with no errors"</h2>
<ol>
<li>Did you call <code>checkDeployStatus()</code> with <code>includeDetails=true</code>?</li>
<li>Is <code>componentFailures</code> empty? If so, look at <code>runTestResult</code>.</li>
<li>In <code>runTestResult</code>, check <code>failures</code> first, then <code>codeCoverageWarnings</code>.</li>
<li>Was the deployment still running when you looked? Check <code>done</code>, and look again when it is true.</li>
<li>If you used <code>RunSpecifiedTests</code>, compare the classes in the package with the classes your named tests cover.</li>
</ol>
<h2>One caution about versions</h2>
<p>The component lists were first on the deployment result itself, and later moved into <code>details</code>. Salesforce says this changed in API version 29.0. If you are reading an old script or an old blog post, check which layout it assumes before trusting where it looks for errors.</p>
<hr />
<p><em>I build</em> <a href="https://diffbridge.com"><em>Diffbridge</em></a><em>, a Salesforce deployment tool, and this post first appeared on its blog. Nothing above needs it. If you spot a mistake in the result details, tell me and I'll fix it.</em></p>
]]></content:encoded></item><item><title><![CDATA[RunLocalTests vs RunSpecifiedTests: why one passes and the other fails with 0% coverage]]></title><description><![CDATA[Two test levels cover almost every production deployment: RunLocalTests and RunSpecifiedTests. They look interchangeable, but they apply different coverage…]]></description><link>https://diffbridge.hashnode.dev/runlocaltests-vs-runspecifiedtests-why-one-passes-and-the-other-fails-with-0-coverage</link><guid isPermaLink="true">https://diffbridge.hashnode.dev/runlocaltests-vs-runspecifiedtests-why-one-passes-and-the-other-fails-with-0-coverage</guid><category><![CDATA[Salesforce]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Apex]]></category><category><![CDATA[Testing]]></category><dc:creator><![CDATA[Diffbridge]]></dc:creator><pubDate>Sat, 28 Nov 2026 19:09:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0ad37f1ff8e7ec687795a4/254601b1-3e19-4c50-b6ac-cd27a011614c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Two test levels cover almost every production deployment: <code>RunLocalTests</code> and <code>RunSpecifiedTests</code>. They look interchangeable, but they apply different coverage rules, and the difference explains a failure many people hit: a deployment that passes with <code>RunLocalTests</code> and fails with <code>RunSpecifiedTests</code> on a class showing 0% coverage. This post sets the two side by side, using Salesforce's Metadata API documentation.</p>
<img src="https://diffbridge.com/blog-images/local-vs-specified.webp" alt="Side by side: RunLocalTests needs 75% overall coverage, RunSpecifiedTests needs 75% on every class in the package, with a made-up example where one class is at 0%" style="display:block;margin:0 auto" />

<h2>What each one runs</h2>
<ul>
<li><code>RunLocalTests</code> runs all tests in your org, except tests that come from installed managed and unlocked packages. It is also the default for a production deployment whose package contains Apex classes or triggers.</li>
<li><code>RunSpecifiedTests</code> runs only the tests you name in the <code>runTests</code> option, and nothing else.</li>
</ul>
<p>Neither is chosen for you by what changed. With the default behaviour, what decides the production test run is what is <em>in the package</em>.</p>
<h2>The coverage rules differ</h2>
<p>This is the part that matters.</p>
<table>
<thead>
<tr>
<th></th>
<th><code>RunLocalTests</code></th>
<th><code>RunSpecifiedTests</code></th>
</tr>
</thead>
<tbody><tr>
<td>Which tests run</td>
<td>All local tests</td>
<td>Only the ones you name</td>
</tr>
<tr>
<td>Coverage required</td>
<td>Overall coverage of at least 75%, and Apex triggers have some coverage</td>
<td>Each Apex class and trigger in the deployment package covered at least 75% <strong>individually</strong></td>
</tr>
<tr>
<td>What the coverage is counted from</td>
<td>All tests that ran</td>
<td>Only the tests you named</td>
</tr>
</tbody></table>
<p>With <code>RunLocalTests</code>, a well-covered org can carry a weak class: only the overall figure has to reach 75%. With <code>RunSpecifiedTests</code>, Salesforce computes coverage for each class and trigger in the package, and it is not the same as the overall percentage.</p>
<h2>Why a specified run fails with 0% coverage</h2>
<p>Here is a made-up example. Take a package with 13 components, including 3 Apex classes, deployed with <code>RunSpecifiedTests</code> and two named tests that cover two of those classes. The third class is covered by neither test. In this run its coverage is 0%, which is below the per-class 75%, so the deployment fails. The full local run would have passed, because the org's overall coverage was fine and the other tests would have covered the third class.</p>
<p>Two fixes follow from the rule:</p>
<ol>
<li><strong>Add the test that covers that class</strong> to the list.</li>
<li><strong>Take the class out of the package</strong> if it hasn't changed. A class that isn't in the package needs no coverage in that run.</li>
</ol>
<h2>Where the failure shows up</h2>
<p>A coverage failure isn't reported with component errors or failing tests. In the Metadata API it appears under <code>details.runTestResult.codeCoverageWarnings</code> in the <code>checkDeployStatus()</code> result, which you only get when you call it with <code>includeDetails=true</code>. If your tooling prints just the error lists, a coverage problem can look like a deployment that failed for no reason.</p>
<h2>Which to pick</h2>
<ul>
<li><strong>Use</strong> <code>RunLocalTests</code> when you want the safest, simplest run and the time isn't a problem, or when you can't say which tests cover which classes.</li>
<li><strong>Use</strong> <code>RunSpecifiedTests</code> when you know the tests for every class in the package and want a much shorter run. Check each class's coverage first.</li>
<li><strong>Remember</strong> <code>RunRelevantTests</code><strong>.</strong> Salesforce marks it as beta. It chooses tests from the deployment payload and its dependencies, so read its current documentation before relying on it.</li>
<li><strong>Remember</strong> <code>NoTestRun</code><strong>.</strong> It applies only to development environments such as sandboxes, Developer Edition and trial orgs, not to production.</li>
</ul>
<p>The Salesforce CLI takes the same choices as <code>--test-level</code> with <code>--tests</code> for the named classes.</p>
<h2>How Diffbridge handles it</h2>
<p>Diffbridge's <strong>Smart</strong> test level uses the same rule for you. If nothing in the package adds, changes or deletes Apex, it runs no tests. If Apex changed, it runs the related tests and shows the plan with reasons first. In production, when a changed class has no related test, it falls back to all local tests, which sidesteps the per-class check that causes the failure above. The <a href="https://diffbridge.com/docs/tests">manual page on tests</a> has the details.</p>
<hr />
<p><em>I build</em> <a href="https://diffbridge.com"><em>Diffbridge</em></a><em>, a Salesforce deployment tool, and this post first appeared on its blog. Nothing above needs it. If you spot a mistake in the test-level details, tell me and I'll fix it.</em></p>
]]></content:encoded></item><item><title><![CDATA[Validate now, deploy later: how Salesforce quick deploy works]]></title><description><![CDATA[Production deployments with Apex tests are slow, and the release window is short. Salesforce has a way to move the slow part out of the window: validate…]]></description><link>https://diffbridge.hashnode.dev/validate-now-deploy-later-how-salesforce-quick-deploy-works</link><guid isPermaLink="true">https://diffbridge.hashnode.dev/validate-now-deploy-later-how-salesforce-quick-deploy-works</guid><category><![CDATA[Salesforce]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Apex]]></category><category><![CDATA[CI/CD]]></category><dc:creator><![CDATA[Diffbridge]]></dc:creator><pubDate>Sat, 28 Nov 2026 18:24:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0ad37f1ff8e7ec687795a4/19596834-e826-470b-843a-b8896fbde5da.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Production deployments with Apex tests are slow, and the release window is short. Salesforce has a way to move the slow part out of the window: validate first, then quick deploy. This post explains what quick deploy is, the conditions Salesforce sets for it, and a workflow that uses it.</p>
<img src="https://diffbridge.com/blog-images/quick-deploy-flow.webp" alt="Three steps: validate, note the ID when it passes, then quick deploy, with the conditions of 10 days, passing tests and met coverage" style="display:block;margin:0 auto" />

<h2>What a quick deploy is</h2>
<p>A deployment can be run as a <strong>validation</strong> (also called a check-only deployment). Salesforce runs everything a real deployment would run, tests included, but saves nothing in the org. If the validation passes, you can later promote it with a <strong>quick deploy</strong>, which deploys the validated components <strong>without running the Apex tests again</strong>.</p>
<p>In the Metadata API this is <code>deployRecentValidation()</code>. In the Salesforce UI it is the quick deploy option on the Deployment Status page. In the Salesforce CLI, <code>sf project deploy validate</code> starts the validation and <code>sf project deploy quick</code> promotes it.</p>
<h2>What Salesforce requires</h2>
<p>From Salesforce's documentation of <code>deployRecentValidation()</code>, all of these must hold:</p>
<ul>
<li>The components were validated successfully <strong>for the target environment</strong> within the last <strong>10 days</strong>.</li>
<li>As part of the validation, <strong>Apex tests in the target org passed</strong>.</li>
<li><strong>Code coverage requirements are met.</strong> If you ran all tests or all local tests, overall coverage is at least 75% and Apex triggers have some coverage. If you used <code>RunSpecifiedTests</code>, each class and trigger that was deployed is covered at least 75% individually.</li>
</ul>
<p>Salesforce also says a validation that finished with passing tests "sometimes" qualifies for a quick deploy, so treat it as something to confirm rather than assume. Trailhead's guidance adds that you should not deploy again or make major changes to the org in between.</p>
<h2>Two consequences</h2>
<ol>
<li><strong>A validation without tests can't be promoted this way.</strong> A quick deploy skips tests because the validation already ran them. If you validated with no tests, there is nothing to skip.</li>
<li><strong>The tests you chose at validation time are the tests you get.</strong> A quick deploy does not add or change tests. If you validate with <code>RunSpecifiedTests</code> and the per-class coverage rule fails, the quick deploy isn't available, and it is better to find that out during validation than during the window.</li>
</ol>
<h2>A workflow that uses it</h2>
<ol>
<li><strong>Validate ahead of the window</strong>, against the same target, with the test level you will rely on. Run it when the package is final.</li>
<li><strong>Check that it passed</strong>, and note its ID (the CLI prints a job ID).</li>
<li><strong>Inside the window, quick deploy</strong> that ID. The deployment skips the tests, so it is much shorter than a full run.</li>
<li><strong>If the package or the target changes</strong> before the window, validate again. A quick deploy promotes one specific validation.</li>
</ol>
<p>The 10-day limit is the one to keep an eye on. A validation from a long weekend before a release may have expired.</p>
<h2>One thing to check first</h2>
<p>On 28 November 2026 we found that <code>sf project deploy validate</code> rejected <code>--test-level NoTestRun</code> in our CLI run. To check a package with no tests you can use <code>sf project deploy start --dry-run --test-level NoTestRun</code> instead, which performs a check-only deployment. That check ran no tests, so there is nothing to quick deploy afterwards. Some answers on Salesforce Stack Exchange also report that a CLI <code>--dry-run</code> is not treated as a validation by <code>sf project deploy quick</code> at all, so use <code>sf project deploy validate</code> when you plan to quick deploy. Check this against your own CLI version.</p>
<h2>How Diffbridge handles it</h2>
<p>In Diffbridge, a validation that ran tests offers <strong>Quick deploy</strong> within the 10-day window: Salesforce deploys the validated package without re-running tests. A validation that ran no tests offers <strong>Deploy this package</strong> instead, which deploys the same zip again. The <a href="https://diffbridge.com/docs/tests">manual page on tests</a> has the details.</p>
<hr />
<p><em>I build</em> <a href="https://diffbridge.com"><em>Diffbridge</em></a><em>, a Salesforce deployment tool, and this post first appeared on its blog. Nothing above needs it. If you spot a mistake in the quick deploy details, tell me and I'll fix it.</em></p>
]]></content:encoded></item><item><title><![CDATA[Three pushes in a row: what should your Salesforce CI do with the stale ones?]]></title><description><![CDATA[Salesforce runs one deployment per org at a time, and a deployment with tests can take a long time. So what should your CI do when new commits arrive while…]]></description><link>https://diffbridge.hashnode.dev/three-pushes-in-a-row-what-should-your-salesforce-ci-do-with-the-stale-ones</link><guid isPermaLink="true">https://diffbridge.hashnode.dev/three-pushes-in-a-row-what-should-your-salesforce-ci-do-with-the-stale-ones</guid><category><![CDATA[Salesforce]]></category><category><![CDATA[Devops]]></category><category><![CDATA[CI/CD]]></category><category><![CDATA[GitHub Actions]]></category><dc:creator><![CDATA[Diffbridge]]></dc:creator><pubDate>Sat, 28 Nov 2026 17:23:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0ad37f1ff8e7ec687795a4/28077edf-e5a9-4149-b0b4-715eb97ed773.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Salesforce runs one deployment per org at a time, and a deployment with tests can take a long time. So what should your CI do when new commits arrive while an older one is still deploying? Most pipelines have no answer, and run every job in order. This post lays out the options and the one condition that decides which are safe.</p>
<img src="https://diffbridge.com/blog-images/stale-pushes-policies.webp" alt="Three policies for stale pushes: run every job, skip stale waiting jobs, and latest wins, with the catch that skipping is only safe when each job deploys the whole branch" style="display:block;margin:0 auto" />

<h2>The scenario</h2>
<p>You have a CI job that validates or deploys on every push to a branch. A deployment takes 25 minutes.</p>
<ul>
<li><strong>0:00</strong> Push 1 arrives and starts running.</li>
<li><strong>0:10</strong> Push 2 arrives and waits.</li>
<li><strong>0:15</strong> Push 3 arrives and waits behind push 2.</li>
</ul>
<p>Run in order, push 3 is live at about 1:15, an hour after you pushed it. If push 3 contains everything from pushes 1 and 2, the first two runs were wasted time.</p>
<h2>Three policies</h2>
<table>
<thead>
<tr>
<th>Policy</th>
<th>What happens</th>
<th>Good for</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Run every job</strong></td>
<td>1, then 2, then 3. Nothing is skipped.</td>
<td>Production deployments, where each merge should have its own run and its own history.</td>
</tr>
<tr>
<td><strong>Skip stale waiting jobs</strong></td>
<td>Push 2 is dropped. Push 1 finishes, then push 3 runs.</td>
<td>Busy CI orgs where you don't want to interrupt a running job but don't need the middle one.</td>
</tr>
<tr>
<td><strong>Latest wins, right away</strong></td>
<td>Push 1 is cancelled and push 2 dropped. Push 3 starts at once.</td>
<td>Validations on pull request or integration branches, where only the newest commit matters.</td>
</tr>
</tbody></table>
<h2>The catch: does each job deploy the whole branch?</h2>
<p>Skipping a job is only safe if the jobs that remain still deploy what the skipped one would have.</p>
<ul>
<li><strong>State-based jobs</strong> compare the whole branch as it is when the job runs against the org, and deploy the differences. Skipping push 2 is safe, because push 3's run includes push 2's changes.</li>
<li><strong>Delta-style jobs</strong> deploy only the files changed in that one push. Skipping push 2 would silently drop its changes unless the tool bundles them into the next run.</li>
</ul>
<p>Before turning on any skipping, find out which kind your tool runs. Diffbridge compares the branch as it is when a job runs, so a commit's sha is only a label, and a skipped push can't leave the org in an older state.</p>
<h2>Cancelling a running deployment</h2>
<p>Cancelling asks Salesforce to stop the deployment. It is a request, not an instant stop:</p>
<ul>
<li>A small deployment can finish before the cancel arrives. In our own testing a superseded job still showed as succeeded for that reason.</li>
<li>If you build this yourself with GitHub Actions, <code>concurrency</code> with <code>cancel-in-progress: true</code> stops the workflow run, but it doesn't by itself cancel a deployment that was already submitted to Salesforce. Your script has to send the cancel and wait for Salesforce to confirm before the next deployment starts.</li>
</ul>
<h2>Rules worth having whatever policy you pick</h2>
<ul>
<li><strong>Limit superseding to the same source.</strong> A newer push to your branch should replace your older ones, not a colleague's unrelated deployment to the same org.</li>
<li><strong>Treat validations and deployments separately.</strong> A newer validation should never replace a waiting deployment, or the other way round.</li>
<li><strong>Never supersede a rollback.</strong></li>
<li><strong>Keep an escape hatch.</strong> An urgent fix shouldn't wait behind a long test run, so you need a way to move one job to the front and cancel the one running.</li>
</ul>
<h2>A reasonable default</h2>
<p>Use <em>Latest wins</em> for validations, where only the newest commit matters, and <em>Run every job</em> for production deployments, where a record of each run is part of the point.</p>
<h2>How Diffbridge does it</h2>
<p>Every connected org has its own lane on the Deploy queue page, with a policy you set per org and can override per CI job: run every job, skip stale waiting jobs, or latest wins right away. Superseding can be limited to the same source, and applied to validations, deployments or both. <strong>Run now</strong> moves a waiting job to the front and cancels the running one. See the <a href="https://diffbridge.com/docs/deploy-queue">manual page on the deploy queue</a> for the details.</p>
<hr />
<p><em>I build</em> <a href="https://diffbridge.com"><em>Diffbridge</em></a><em>, a Salesforce deployment tool, and this post first appeared on its blog. The advice above applies to any pipeline. If your tool handles stale pushes differently, tell me in the comments and I'll add it.</em></p>
]]></content:encoded></item><item><title><![CDATA[When does Salesforce run Apex tests on a deployment, and how do you run fewer?]]></title><description><![CDATA[Apex tests are the slowest part of most Salesforce deployments to production. This post explains when Salesforce runs them, which levels you can choose…]]></description><link>https://diffbridge.hashnode.dev/when-does-salesforce-run-apex-tests-on-a-deployment-and-how-do-you-run-fewer</link><guid isPermaLink="true">https://diffbridge.hashnode.dev/when-does-salesforce-run-apex-tests-on-a-deployment-and-how-do-you-run-fewer</guid><category><![CDATA[Salesforce]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Apex]]></category><category><![CDATA[Testing]]></category><dc:creator><![CDATA[Diffbridge]]></dc:creator><pubDate>Sat, 28 Nov 2026 16:06:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0ad37f1ff8e7ec687795a4/39dfa557-e132-476c-ae70-391b1e845a6c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Apex tests are the slowest part of most Salesforce deployments to production. This post explains when Salesforce runs them, which levels you can choose, the coverage rules that limit your options, and five practical ways to run fewer tests without breaking a deployment.</p>
<img src="https://diffbridge.com/blog-images/production-test-run.webp" alt="Flowchart: if the package contains Apex classes or triggers, a production deployment runs all local tests; if it contains none, no tests run" style="display:block;margin:0 auto" />

<h2>The test levels</h2>
<p>A Metadata API deployment takes a test level. These are the ones the Salesforce CLI offers today:</p>
<table>
<thead>
<tr>
<th>Level</th>
<th>What runs</th>
</tr>
</thead>
<tbody><tr>
<td><code>NoTestRun</code></td>
<td>No tests.</td>
</tr>
<tr>
<td><code>RunSpecifiedTests</code></td>
<td>Only the test classes you name.</td>
</tr>
<tr>
<td><code>RunLocalTests</code></td>
<td>Every test in your org except tests from installed managed and unlocked packages.</td>
</tr>
<tr>
<td><code>RunAllTestsInOrg</code></td>
<td>Every test, including managed-package tests.</td>
</tr>
<tr>
<td><code>RunRelevantTests</code></td>
<td>Salesforce chooses tests based on the components in the package. Currently a beta option, so check Salesforce's documentation for its API version and limits.</td>
</tr>
</tbody></table>
<h2>What runs if you don't choose</h2>
<p>If you don't pick a level, Salesforce uses a default that depends on where you deploy:</p>
<ul>
<li><strong>Sandboxes and Developer Edition orgs:</strong> no tests.</li>
<li><strong>Production:</strong> all local tests if the package contains Apex classes or triggers, and none if it doesn't. Gearset's documentation of this default also counts Flows that are set to activate on deployment, so check your own package for those (<a href="https://docs.gearset.com/en/articles/1376067-setting-apex-test-levels">their page</a>).</li>
</ul>
<p>That second rule is the source of most surprise slow deployments. The test run isn't triggered by what you <em>changed</em>; it is triggered by what is <em>in the package</em>.</p>
<h2>The coverage rules</h2>
<p>Two rules decide whether a production deployment can pass:</p>
<ul>
<li>With <code>RunLocalTests</code> or <code>RunAllTestsInOrg</code>, the org needs at least 75% Apex code coverage overall, and every test that runs must pass.</li>
<li>With <code>RunSpecifiedTests</code>, each Apex class and trigger in the package needs at least 75% coverage <em>on its own</em>, from the tests you named.</li>
</ul>
<p>The second rule is why "just run the tests for my class" sometimes fails in production when the full run would have passed: a class in the package with no test among your picks has zero coverage in that run.</p>
<h2>Five ways to run fewer tests</h2>
<ol>
<li><strong>Keep unchanged Apex out of the package.</strong> Change sets, "select all" and dependency add-ons often pull in classes that haven't changed. In production, any Apex in the package means a full local test run. Compare your source against the target and deploy only the differences.</li>
<li><strong>Specify the tests, and check coverage per class.</strong> <code>RunSpecifiedTests</code> can cut a run from hundreds of classes to a handful, as long as every class in the package is covered by one of them.</li>
<li><strong>Consider</strong> <code>RunRelevantTests</code><strong>.</strong> Salesforce marks it as beta. It lets Salesforce choose the tests, so read its current documentation for the limits before relying on it for production.</li>
<li><strong>Validate ahead, quick deploy later.</strong> Run a validation with tests while you wait for the release window. A validation that ran tests and passed can be promoted with a quick deploy, which deploys the validated package without running the tests again. Salesforce allows this within 10 days of the validation.</li>
<li><strong>Ship configuration separately from code.</strong> A package with no Apex needs no tests at the default level, so layouts, fields and permission changes don't have to wait behind a code release. Check any Flows in the package first.</li>
</ol>
<h2>What we checked, and what we didn't</h2>
<p>On 28 November 2026 we ran check-only deployments, which change nothing in the org, against a Developer Edition org with an explicit <code>NoTestRun</code>. A custom label validated, and so did an active Flow. Salesforce counts Developer Edition as a development environment, where <code>NoTestRun</code> is the default, so this does not show what happens in production, and we have not yet tested a production org. Treat the Flow point above as unverified until you run a validation against your own production org.</p>
<h2>How Diffbridge automates this</h2>
<p>Diffbridge's <strong>Smart</strong> test level applies the same ideas for you on every deployment, and shows the plan, with reasons, before you start:</p>
<ul>
<li>Apex that is byte-identical to the target is dropped from the package, so it can't force a test run.</li>
<li>If nothing in the package adds, changes or deletes Apex, the deployment runs with <code>NoTestRun</code>, even into production.</li>
<li>If Apex changed, it runs the related tests: test classes in the package, tests matching naming conventions such as <code>FooTest</code>, tests that reference the changed class, and for triggers, tests that use the trigger's object.</li>
<li>In production, if a changed class has no related test, it falls back to all local tests instead of risking a coverage failure.</li>
</ul>
<p>Smart picks related tests by name and by reference, so a test that exercises code only indirectly can be missed. The production fallback covers the case where a changed class has no related test at all. You can always override the plan and hand-pick tests. The <a href="https://diffbridge.com/docs/apex-tests">manual page on Smart tests</a> has the details.</p>
<hr />
<p><em>I build</em> <a href="https://diffbridge.com"><em>Diffbridge</em></a><em>, a Salesforce deployment tool, and this post first appeared on its blog. Nothing above needs it. If you spot a mistake in the test-level details, tell me in the comments and I'll fix it.</em></p>
]]></content:encoded></item></channel></rss>