Sub topic 6
Testing in a Sandbox First
This chapter assumes you know basic Salesforce administration (Setup, profiles, permission sets) and the difference between a sandbox and a production org. It covers why a sandbox trial comes before production, how to run one, and what to look for.
Why a sandbox trial comes first
A package changes your org. It can add objects, fields, Apex code, triggers, flows, and permission sets. Some of those changes touch data and automation that already exist. A sandbox is a copy of your org's configuration, and optionally its data, where a failed install costs you nothing permanent.
A sandbox trial answers three questions:
- Does the app install cleanly in an org that looks like yours?
- Does it conflict with your existing customizations, such as triggers, validation rules, or flows on the same objects?
- Does it do what the listing says, for the people who will actually use it?
Production only gets the app after all three answers are yes.
Choose the right sandbox
The sandbox type decides how realistic your test is.
| Sandbox type | Copies | Best for |
|---|---|---|
| Developer | Configuration only | Quick install checks |
| Developer Pro | Configuration only, more storage | Larger configuration checks |
| Partial Copy | Configuration plus a data sample | Realistic user testing |
| Full | Configuration plus all data | Volume and performance checks |
Use a Partial Copy or Full sandbox if the app reads or writes large amounts of data. A Developer sandbox can hide problems that only appear with real record volumes or data shapes.
Refresh the sandbox first if it is old. A sandbox that no longer matches production gives you results you cannot trust.
Install in the sandbox
Get the package version ID from the listing. It starts with 04t. Install it with the Salesforce CLI and restrict access to administrators until you decide otherwise.
sf package install --package 04tXXXXXXXXXXXXXXX --target-org my-sandbox --security-type AdminsOnly --wait 10Replace the placeholder with the real ID. --security-type AdminsOnly limits the app's access to administrators. --wait 10 makes the command wait up to 10 minutes for the install to finish.
Confirm what is now in the org:
sf package installed list --target-org my-sandboxThe output shows the package name, namespace, and installed version. Compare it with the version you meant to install.
Test with minimal access
Do not test as a System Administrator only. Administrators see almost everything, so they hide permission problems that regular users will hit.
Assign one of the app's permission sets to a single test user. Use the real permission set name from the app.
sf org assign permset --name Example_App_User --target-org my-sandbox --on-behalf-of [email protected]Then log in as that user, or use Login As, and try the app. If the user cannot do their job, you have found a gap in the permission set choice before it affects anyone in production. If the user can see more than they should, you have found a least-privilege problem.
Build realistic scenarios
Write down a short list of scenarios before you start. Base them on real work, not on the vendor's demo.
- The main task the app exists for, start to finish.
- A task done by a user with limited access.
- A record that already has automation attached, such as a flow or trigger.
- Bulk behavior: load or update a few hundred records and watch for errors.
- A failure case, such as missing required data or a disabled integration user.
What to watch for
While you test, check for side effects, not only for the feature working.
- Governor limit errors. Apex from the package shares limits with your own code in the same transaction. Bulk operations can fail with "Too many SOQL queries" errors.
- Changed behavior on existing records. Compare a few records before and after.
- New automation. Review the new triggers, flows, and scheduled jobs in Setup.
- Outbound calls. Check Remote Site Settings and Named Credentials the package added, and confirm they match what the listing disclosed.
- Performance. Note page load times on objects the app touches.
Keep notes of what you tested and what you saw. You will need them for the production decision and for any conversation with the publisher.
Rehearse the uninstall
Test removal while you are still in the sandbox. Uninstalling can fail or leave work behind, for example when your own code or reports reference the package's components.
sf package uninstall --package 04tXXXXXXXXXXXXXXX --target-org my-sandbox --wait 10If the uninstall is blocked, the error names the dependencies. Knowing this now tells you how hard a rollback in production would be.
Common mistakes
- Testing only as an administrator.
- Using an outdated sandbox that no longer matches production.
- Testing with a handful of records when production has millions.
- Skipping the uninstall rehearsal.
- Assuming a sandbox pass means the production install is identical. Data volume, integrations, and user mix can still differ.
Exercise
You installed an app in a Developer sandbox as an administrator and everything worked. Name two reasons this is not enough to approve it for production.
Show answer
First, administrators have broad access, so the test hides permission problems regular users would hit. You should assign the app's permission set to a test user with minimal access and test as that user. Second, a Developer sandbox has no real data volume, so bulk and performance problems stay hidden. A Partial Copy or Full sandbox with realistic scenarios gives better evidence. Rehearsing the uninstall is also still needed.