Code Coverage Enforcement for Unlocked Packages

Meeting code coverage requirements helps validate that the Apex code in your unlocked packages has adequate test coverage. Starting in Winter ’21, a minimum 75% code coverage is required for package version promotion. Package versions created in Winter ’21 and later that don’t meet this code coverage can be installed only in scratch orgs and sandboxes.

Where: This change applies to unlocked package versions created using Salesforce CLI or Tooling API.

How: You can use the codecoverage CLI parameter on the force:package:version:createor the CalculateCodeCoverage field in the Package2VersionCreateRequest object when you create a package version.

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