Optimized Installation

AttributeTypeDescriptionPackage Types Applicable
isOptimizedDeploymentbooleanWhen true (default), a source package deploys with the test classes it contains, a diff package deploys with RunRelevantTests, and a package bound to a deployment test suite runs its bound tests. Set to false to deploy with RunLocalTests, even when the package is bound
  • source
  • diff



sfp cli optimally deploys artifacts to the target organisation by reducing the time spent on running Apex tests where possible. This section explains how this optimisation works for different package types.

Package TypeApex Test Execution during installationCoverage Requirement
Unlocked PackageNo75% for the contents of a package validated during build
Org Dependent Unlocked PackageNoNo
Source PackageYesYes, either each classes need to have individual 75% coverage or use the entire org's apex test coverage
Diff PackageYesYes, either each classes need to have individual 75% coverage or use the entire org's coverage
Data PackageNoNo

To ensure salesforce deployment requirements for source packages, each Apex class within the source package must achieve a minimum of 75% test coverage. This coverage must be verified individually for each class. It's imperative that the test classes responsible for this coverage are included within the same package.

During the artifact preparation phase, sfp cli will automatically identify Apex test classes included within the package. These identified test classes will then be utilised at the time of installation to verify that the test coverage requirement is met for each Apex class, ensuring compliance with Salesforce's deployment standards.

When there are circumstances, where individual coverage cannot be achieved by the apex classes within a package, one can disable 'optimized deployment' feature by using the attribute mentioned below.

This option is only applicable to source/diff packages. Disabling this option will trigger the entire local tests in the org and can lead to considerable delays. A source package installed with sfp install --use-relevant-tests deploys with RunRelevantTests instead

// Demonstrating how to disable optimized deployment
{
  "packageDirectories": [
    {
      "path": "core-crm",
      "package": "core-crm",
      "versionDescription": "Package containing core schema and classes",
      "versionNumber": "4.7.0.NEXT",
      "isOptimizedDeployment": false
    },
     ...
   ]
}

When the tests that cover a package live in another package, bind the package to a test suite instead of disabling optimized deployment. The package then deploys with exactly the suite's tests. See Deployment test suites.