Sub topic 9
Regression testing before the upgrade
This chapter assumes you can work in Setup, know the difference between sandbox and production, have used Flow, Apex and Lightning customizations, and can run a command in a terminal. Regression testing is the step where the earlier work pays off. You have read the release notes, assessed the impact and put a sandbox on the preview instance. Now you check that what worked before the upgrade still works after it.
What regression testing means for a Salesforce release
A regression is something that worked on the current release and stops working, or works differently, on the new one. Salesforce tests its own platform extensively. It cannot test your combination of custom Apex, Flows, validation rules, managed packages and integrations. Only you can.
You are not testing the new features. You are testing your existing behavior on the new release. New features come later, once the baseline is safe.
Regressions usually come from these sources:
- Behavior changes in the platform, such as a different order of execution detail or a stricter validation.
- Release Updates that Salesforce enforces on a set date.
- Changes in managed packages that were upgraded for the new release.
- Fragile customizations, such as Apex that depends on undocumented behavior or Lightning components that rely on internal DOM structure.
- Integrations that call APIs whose behavior or limits changed.
Plan the scope from the impact assessment
You cannot test everything. Use the impact assessment from the previous chapters to rank what to test. A useful ranking has three tiers.
| Tier | What it covers | Test depth |
|---|---|---|
| 1. Critical | Revenue and compliance processes, such as lead to opportunity to order, case escalation, and billing integrations | Full automated and manual test, every release |
| 2. Important | Daily team workflows, reports and dashboards, and Flows that update many records | Automated tests plus a sampled manual check |
| 3. Low | Rarely used features and cosmetic customizations | Smoke check, or only when the release notes mention them |
Add every item that the release notes or the Release Updates page flagged as relevant to your org, regardless of tier. A flagged item is a known risk and deserves a targeted test.
Choose the right environment
The preview window is the period when sandboxes and pre-release orgs run the new release while production still runs the old one. You can only run a true regression test inside that window. The environments differ in how well they reflect production.
| Environment | Strength | Weakness |
|---|---|---|
| Preview full or partial sandbox | Production-like data volume, configuration and integrations | Slow to refresh, and a refresh may move it off the preview instance |
| Preview developer sandbox | Quick to refresh, good for Apex and Flow tests | Small data set, so volume and performance problems stay hidden |
| Preview scratch org | Disposable, scriptable, ideal for CI | Contains only the metadata you deploy, with no real data or production integrations |
Check the sandbox instance before you rely on it. If you refreshed a sandbox after the preview cutoff, it may be on the non-preview release. Look at the sandbox's release version in Setup, or compare its instance against the published preview list. Testing on the wrong release gives a false pass.
Prepare the preview environment
A test only means something if the environment matches production. Before you run anything, do these steps.
- Confirm the environment is on the preview release.
- Deploy the same metadata that is in production, not your in-progress development branch. Mixing unreleased work into the test makes failures hard to attribute.
- Install the same managed package versions as production.
- Load or confirm representative data. Include records with edge cases: null fields, very long text, records owned by inactive users, and large parent records with many children.
- Recreate the permission model. Test with real profiles and permission sets, not only as a System Administrator, because admins bypass many failures that regular users hit.
A preview scratch org
When you need a clean, scripted environment, create a scratch org on the preview release. The definition file sets the release option to Preview.
{
"orgName": "Release Preview Org",
"edition": "Developer",
"release": "Preview"
}Create the org from that file and make it your default target.
sf org create scratch \
--definition-file config/project-scratch-def.json \
--alias preview-org \
--duration-days 7 \
--set-defaultThe release option only has an effect while a preview is available. Outside the preview window, the scratch org is created on the current release.
Run automated Apex tests
Apex tests are the cheapest regression check you have. They run quickly and they catch compile errors and logic changes. Run all local tests, which means every test in your org except those from installed managed packages.
sf apex run test \
--target-org my-preview-sandbox \
--test-level RunLocalTests \
--result-format human \
--wait 20The --wait 20 option makes the command wait up to 20 minutes. Large orgs can take longer, so raise it or run asynchronously and fetch results later.
Compare the result with a baseline. Run the same command against a non-preview sandbox that has identical metadata. A failure that appears only on the preview sandbox is a likely regression. A failure that appears on both is an existing problem that you should fix, but it is not caused by the release.
Interpret failures carefully
- Assertion failures often point to a behavior change. Read the failing assertion and check the release notes for the feature involved.
- Compile errors usually mean a referenced class, field or method changed or was retired.
- Intermittent failures that pass on a rerun often indicate a test that depends on data or timing, not a release problem. Fix the test, because flaky tests hide real regressions.
- Governor limit errors can appear when the platform changes how work is counted or when a new managed package version adds queries. Check the debug log for the limit that was hit.
Test Flows
Flows are metadata that run at save time or on a schedule, and many orgs have far less automated test coverage for them than for Apex. Cover them with these methods.
- Use Flow tests in Flow Builder for record-triggered flows. They run in a test context and can be run for each flow before and after the upgrade.
- Use Debug in Flow Builder to step through screen flows and autolaunched flows with specific inputs.
- Trigger record-triggered flows through Apex tests or through manual data changes that you know should fire them.
- For scheduled flows, run them against a preview sandbox with a small data set, and check the run results in the Paused and Failed Flow Interviews list and in the flow error emails.
Pay attention to flows that interact with Apex triggers on the same object. Both run in the same transaction. A platform change in order of execution detail, or a new validation, can change the outcome only when both are active.
Test key user journeys
Some regressions only appear in the user interface: a Lightning page layout that renders differently, a custom Lightning web component that breaks, a button that moved. Define the user journeys that matter, write each as a short script, and run it with a real user profile.
A good journey script has five parts:
- The profile or permission set to test with.
- The starting data.
- The steps, written so that someone else can follow them.
- The expected result.
- The pass or fail record, with a screenshot on failure.
Examples of Tier 1 journeys are creating a lead and converting it, closing an opportunity with products, opening and escalating a case, and running the month-end report. Include the mobile app if your users depend on it, and any Experience Cloud site you operate.
Do not forget integrations. Run each inbound and outbound integration against the preview sandbox, using the sandbox's own endpoint and credentials. Check authentication, payload formats, error handling and response times. If the sandbox cannot reach a downstream system, record that as an untested risk instead of marking it as passed.
Handle the results
Record each defect with the environment and release version, the steps to reproduce, the expected and actual behavior, and the related release note or Release Update if there is one. Then decide where the cause lies.
| Cause | Action |
|---|---|
| Your code or configuration | Fix it in the development branch, deploy to the preview sandbox, and retest |
| A managed package | Contact the vendor and ask for a compatible version before the production upgrade |
| A Release Update | Fix the underlying issue, or activate the update early in the sandbox to confirm the fix |
| A suspected platform bug | Open a Salesforce Support case with a minimal reproduction and the preview instance name, and ask whether a fix or workaround is scheduled |
Retest after every fix, and rerun the whole Tier 1 set at least once before sign-off, because a fix in one area can break another.
Know when you are done
You can sign off when these conditions hold:
- All local Apex tests pass on the preview environment, or each failure has a documented cause that is not a regression.
- Every Tier 1 journey passes with a real profile.
- Every item flagged in the impact assessment has been tested.
- Open defects have an owner and a plan that finishes before the production upgrade date.
Record the result in your release-readiness checklist, which the later chapter on that topic builds in full. Be honest in the record about what you did not test. An accurate list of gaps tells the support team where to look first after the upgrade.
Exercise
Your Apex tests pass on a developer sandbox, but a Tier 1 case-escalation flow fails for a service agent and works for a System Administrator. Name two likely reasons that the first test run did not catch this, and say what you would change in the process.
Show answer
First, the developer sandbox has little data, so edge-case records that trigger the failure were absent. Second, the test ran as an administrator, who bypasses field-level security, sharing and permission gaps that a service agent hits. Apex tests also do not exercise a Flow's full user path. Change the process by testing the journey with the real service agent profile or permission set, loading representative edge-case data, and adding a Flow test or a scripted journey for case escalation to the Tier 1 list.
Exercise
You created a scratch org on Preview two weeks after the preview window closed, and your tests pass. Why can you not treat the result as evidence for the new release, and how do you check?
Show answer
The release option only takes effect while a preview is available. After the window closes, the scratch org is created on the current release, which production may already be running, so the test shows nothing about the upgrade. Check the org's release version in Setup or in the org details before you trust the result, and run the tests again in a sandbox or scratch org that is confirmed to be on the target release.