Code Coverage for Unlocked Packages

Before you can promote and release an unlocked package, the Apex code must meet a minimum 75% code coverage requirement. You can install package versions that don't meet code coverage requirements only in scratch orgs and sandboxes.

Unlocked package versions that were promoted to the released state before Winter ‘21 aren’t subject to code coverage requirements.

Important

To compute code coverage using Salesforce CLI, use the --code-coverage parameter when you run the sf package version create command.

Package version creation can take longer to complete when code coverage is being computed, so consider when in the development cycle to include the code coverage parameter. You can choose to skip code coverage, and you can skip all validation by specifying the --skip-validation parameter. You can promote package versions only if they’re validated and meet code coverage requirements.

View code coverage information for a package version using sf package version list with the --verbose parameter, or the sf package version report command in Salesforce CLI.

We don’t calculate code coverage for org-dependent unlocked packages.