Sub topic 6
Testing in a Sandbox First
This chapter assumes you can navigate Setup, know the difference between profiles and permission sets, and understand that a sandbox is a copy of a production org used for development and testing. You should also know roughly which data and customizations your production org holds. The chapter covers why the sandbox trial comes before production, how to choose a sandbox type, how to install a package there, and how to test it against realistic scenarios.
Why a sandbox trial comes first
Earlier chapters covered how to vet a publisher, what the Security Review does and does not guarantee, and what access a package requests. Those steps reduce risk, but they are all based on documents and listings. A sandbox trial shows you what the app actually does in an org that looks like yours.
A package can behave differently in your org than in the publisher's demo for several reasons:
- Your org has custom fields, validation rules, flows, and Apex triggers that run on the same objects the app touches.
- Your org has data volumes and sharing rules that the publisher never tested against.
- Your org may have limits that are close to being reached, such as custom object counts or API usage.
- Your users have profiles and permission sets that decide what they can see.
A sandbox lets you find these problems without exposing customer records or interrupting users. It also lets you rehearse the install and the uninstall, so production steps are familiar when you get there.
Choosing the right sandbox type
Salesforce offers several sandbox types. They differ in what they copy from production and how often you can refresh them. The names and limits depend on your edition, so check your own org under Setup, Sandboxes.
| Sandbox type | What it copies | Typical use for an app trial |
|---|---|---|
| Developer | Configuration and metadata only, with small data storage | Quick check that the package installs and the UI works |
| Developer Pro | Configuration and metadata only, with more data storage | Same as Developer, with room for larger test data sets |
| Partial Copy | Configuration plus a sample of production data | Testing against realistic records without a full copy |
| Full | Configuration and all production data | Performance and volume testing, final dress rehearsal |
For most trials, a Partial Copy sandbox is a good balance. Developer sandboxes are fast to create and refresh, but they have no production data, so you must create test data yourself. A Full sandbox is the only type that shows how an app performs against real data volumes, but it takes longer to create and can usually be refreshed less often.
If your production org has sensitive data, treat a sandbox that copies it as sensitive too. A sandbox copy of customer data carries the same privacy obligations as production. Consider a data masking approach or a sandbox that starts with no data.
Prepare the sandbox
Do a little preparation before you install. It makes the test result meaningful.
- Refresh or create the sandbox so its metadata matches current production. A stale sandbox hides conflicts with recent changes.
- Confirm the sandbox email deliverability setting, as described above.
- Create or identify test users that mirror your real roles, such as a sales rep, a manager, and a read-only user. Test with these users, not only with your own administrator account, because administrators see almost everything and hide permission problems.
- Write down a baseline. Note the number of custom objects, the storage used, and any scheduled jobs. You will compare against this after the install.
- Write down the scenarios you will test, based on the real business process the app supports.
Install the package in the sandbox
You can install from the AppExchange listing by choosing the sandbox option, or by using the Salesforce CLI with a package version ID. The package version ID starts with 04t. The CLI is useful because it makes the install options explicit and repeatable.
sf package install --package 04tXXXXXXXXXXXXXXX --target-org my-sandbox --security-type AdminsOnly --wait 10Replace the placeholder with the real 04t ID from the listing. The flags matter:
--packagenames the package version to install.--target-orgnames the org by alias. Check this carefully. The alias decides where the package goes, so confirm it points to the sandbox and not to production.--security-type AdminsOnlylimits access to administrators after install. You then grant access to specific users deliberately, which is the least-privilege approach covered in the next chapters.--wait 10makes the command wait up to 10 minutes for the install to finish, instead of returning immediately.
The install can take a while for large packages. When it finishes, list the installed packages to confirm the result.
sf package installed list --target-org my-sandboxThe output shows the package name, namespace, version, and ID. Compare the version with the one on the listing. If the version is not the one you expected, stop and find out why before you test.
Some packages ask for approval of third-party access during installation, for example a remote site or connected app that the package uses. Read this prompt. It should match the external connections you noted when you reviewed requested access. If the package asks for something you did not expect, that is a finding to record, not a prompt to click through.
Give a test user limited access
After an install with AdminsOnly, ordinary users cannot use the app. Assign one of the app's permission sets to a single test user, so you can see what minimal access looks like.
sf org assign permset --name Example_App_User --target-org my-sandbox --on-behalf-of [email protected]Use the real permission set name from the app. You can find the names in Setup, under Permission Sets, usually with the package namespace as a prefix. Many apps provide separate sets, for example an administrator set and a user set. Start with the lowest one that lets the test user do the job.
Also check whether the app requires a package license for each user. If the user has no license, the permission set assignment can fail or the app can show no features. This is a licensing finding to record for the production plan.
Test against realistic scenarios
A successful install only shows that the package is present. The trial is meant to answer these questions:
- Does the app do the job it was bought for, using your data and your process?
- Does it respect the access you gave it, and nothing more?
- Does it interfere with anything else in the org?
- What does it cost in limits, performance, and administration?
Turn each question into test cases.
Functional tests
Walk through the main business process end to end with a real-looking record. If the app syncs leads, create leads with your required fields and picklist values. If it generates documents, use your real templates and record types. Test the edges too: empty fields, long text, special characters, records owned by other users, and records in each of your record types.
Access tests
Log in as the test users, or use the "Log in" action from Setup, Users, if your org allows it. Check these cases:
- A user with no permission set cannot see the app or its data.
- A user with the minimal permission set can do the intended tasks, and no more.
- A read-only user cannot edit app records.
- A user outside the sharing rules cannot see records they should not see.
Compare what you find with the permissions the app declared. If a test user can see data you did not expect, check the package's object and field permissions, and check whether the app runs code in a mode that ignores sharing.
Interaction tests
Your org's automation can collide with the package. Look for these effects:
- Your validation rules block records the app creates, or the app's records break your validation.
- A flow or trigger you own fires on app-created records and does something unintended.
- The app updates fields your own automation also updates, which can cause loops or overwritten values.
- Governor limits are exceeded when a bulk load meets both your automation and the app's.
Run a bulk test as well as single-record tests. Load a few hundred records through the app or through Data Loader and watch for errors in the results.
External connection tests
If the app calls an outside service, check what it sends. Use Setup, Remote Site Settings, Named Credentials, and Connected Apps to see the endpoints. Where you can, review which fields leave the org. Use test data only, so that a surprise does not become a data leak. Event Monitoring or debug logs can help here if you have access to them.
Resource and performance tests
Compare against your baseline. Check Setup, Storage Usage, and the API usage in System Overview. Note scheduled jobs the package added under Scheduled Jobs, and look at page load times on the pages where the app adds components.
Record what you learn
Keep short notes on each test: the scenario, the user, the expected result, the actual result, and whether it passed. These notes serve three purposes. They are the evidence for the go or no-go decision. They become the production runbook for the install steps and the permission set assignments. They are also a record you can show an auditor or a manager.
A reasonable decision rule is this: do not move to production until every must-have scenario passes, every unexpected access or connection is explained, and the uninstall rehearsal works. The next chapters cover install options and uninstalling in more detail.
Rehearse the uninstall
The sandbox is the right place to learn what removal involves. Uninstalling a package removes its components, but it can be blocked or can lose data.
sf package uninstall --package 04tXXXXXXXXXXXXXXX --target-org my-sandbox --wait 10Common problems you can find now, rather than in production:
- Your own metadata references a package component, such as a page layout that includes an app field or a flow that uses an app object. The uninstall fails until you remove those references.
- Data in the package's custom objects and fields is deleted, and Salesforce keeps it only for a limited time in a recoverable state. Export what you need before you uninstall.
- Unmanaged package components are not removed this way, because an unmanaged package has no installed package record that can be uninstalled as a unit. Each component has to be deleted separately.
Reinstall afterward if you want to continue testing. The goal is to know how long the process takes and what must be cleaned up.
Common mistakes
- Testing only as a system administrator, which hides missing permissions.
- Using a Developer sandbox with no data and then assuming the app works with production volumes.
- Leaving email deliverability on in a sandbox copied from production.
- Treating the sandbox result as final after the sandbox falls behind production changes. If production changes materially between the trial and the install, repeat the affected tests.
- Skipping the uninstall rehearsal.
- Using the wrong org alias in the CLI.
Exercise
You installed an app into a Partial Copy sandbox with --security-type AdminsOnly. Your sandbox tests passed when you were logged in as a system administrator. Name two further checks you should run before approving the app for production, and say why the administrator tests were not enough.
Show answer
Assign the app's minimal permission set to a test user with a realistic profile, such as a sales rep, and confirm the user can do the job and cannot see or edit anything extra. Also run an uninstall rehearsal, and a bulk test with your own validation rules and automation active. Other valid checks are verifying external connections and comparing storage and API usage with the baseline. Administrator tests were not enough because administrators have broad access, so they hide missing permissions, sharing problems, and license issues that ordinary users would hit.
Exercise
Why should you check the sandbox email deliverability setting before testing an app in a sandbox created from production data?
Show answer
A sandbox copy can contain real customer email addresses. If the app, or your own automation triggered by it, sends email, real customers could receive test messages. Setting deliverability to "System email only" stops those messages.