Sub topic 1
How Deployments Reach a Target Org
Prerequisites
Assume you know basic Salesforce metadata, Apex classes, triggers, custom objects, sandboxes, production orgs, and the sf CLI. You should also know that production deployments require Apex tests and code coverage.
Deployment path
A deployment moves metadata from a source project or sandbox into a target org. The target org is the Salesforce org that receives the change. For a production release, the usual path is:
A deployment can include Apex, custom objects, fields, permissions, and other metadata. Salesforce checks dependencies, tests, and deployment rules against the target org.
Choosing a test level
A test level controls which Apex tests Salesforce runs during deployment.
| Test level | Tests run | Typical use |
|---|---|---|
| `RunLocalTests` | Tests in the target org, excluding installed-package tests | Most production deployments |
| `RunAllTestsInOrg` | All tests, including installed-package tests | Rare, broad verification |
| `RunSpecifiedTests` | Only named tests | Controlled deployments with coverage evidence |
| `NoTestRun` | No tests | Usually permitted only outside production |
RunLocalTests is the common production choice. Use RunSpecifiedTests only when the named tests cover the deployed Apex and your release process allows that narrower scope.
Code coverage rules
Salesforce checks both test success and coverage. Production deployments generally require at least 75% overall Apex code coverage. Every deployed Apex class and trigger also needs coverage. A passing test run does not guarantee that the deployment meets coverage requirements.
What validation changes
A validation-only deployment runs deployment checks without saving the metadata changes in the target org. It can still consume deployment time and produce a deployment job ID. Save that ID because a successful validation may support a later quick deploy.
sf project deploy validate \
--manifest manifest/package.xml \
--test-level RunLocalTests \
--target-org prodValidation does not make the new Apex, fields, or permissions available to users. It also does not guarantee that the target org will remain unchanged before the later deployment. Changes to dependencies or org configuration can affect the release.
Exercise
Does a successful validation change production metadata?
Show answer
No. It checks whether the deployment can succeed but does not save the changes.