Sub topic 3
Choosing an Apex Test Level for Change Set Deployments
Assume you know Salesforce Setup, sandboxes, metadata types, and the difference between configuration and data. You also need deployment permissions and access to the related orgs.
Choosing an Apex test level
The test level controls which Apex tests Salesforce runs during deployment.
- RunSpecifiedTests runs only the tests you select. Use it when the change set contains focused Apex changes and you know the relevant tests.
- RunLocalTests runs tests written in the target org, excluding managed-package tests. This is commonly suitable for production deployments.
- RunAllTestsInOrg runs all tests, including managed-package tests. It gives broader coverage but usually takes longer.
- Default lets Salesforce choose the platform default. Check the deployment screen rather than assuming which tests will run.
For production, Apex tests generally must meet the required code-coverage rules. A passing test run does not guarantee deployment success: metadata dependencies and other validation rules can still fail.
Deploying and reading deployment status
In the target org, open the inbound change set and choose Validate before deployment. Validation checks components and tests without committing changes. Review the component list, test results, code coverage, and error messages. After a successful validation, choose Deploy. Monitor the deployment record until it is Succeeded or Failed.
A validation result can expire, so deploy within the period shown by Salesforce.
Manual steps after deployment
Change sets do not perform every operational task. Plan separately for:
- Loading data or updating custom settings.
- Assigning permission sets or checking user access.
- Activating flows, approval processes, or other inactive automation.
- Updating integrations, endpoints, or scheduled jobs.
- Verifying reports, pages, and business processes with users.
What change sets cannot do
Change sets work only between related orgs with an authorized deployment connection. They do not move ordinary record data, provide reliable version history, or offer convenient branching and merging. Some metadata types are unsupported or require manual recreation.
Troubleshooting failed deployments
Read the first meaningful error, then check:
- Missing dependent components in the change set.
- A test failure caused by changed behavior or test data assumptions.
- Insufficient code coverage.
- Conflicting names or existing components in the target.
- Permissions or inactive automation.
Fix the source org, update the change set, upload it again, and validate again.
When to use other deployment tools
Use change sets for occasional, administrator-managed moves between related orgs. Choose Salesforce CLI with source control for repeatable deployments, reviewable history, and automation. Use a DevOps platform when you need approvals, pipelines, dependency analysis, or promotion across many orgs.
Exercise
Which test level is usually a practical choice for a production deployment containing Apex owned by your team?
Show answer
RunLocalTests, provided the local tests meet coverage and correctly test the changed behavior.