I am facing this below error while promoting 2g package

Error (1): The code coverage required to promote this version has not been met. Please add additional test coverage and ensure the code coverage check passes during version creation.

My test class has 100% code coverage and I'm getting below result when I run test from VS code

TEST NAME                               OUTCOME  MESSAGE  RUNTIME (MS)
──────────────────────────────────────  ───────  ───────  ────────────
CTTest.testSendFile                     Pass              574 

Below is the command used for promoting package:

Sfdx force:package:version:promote -p PACKAGEVERSIONNAME -v TARGETDEVHUBUSERNAME

Few more queries :

  1. When we plan to submit the package, do we need to create a Developer edition org in PBO , install the package and submit the same for review?
  2. Let's say we have developed an app in an org(which has multiple classes, VF page, lightning components) and it doesn't have namespace. what will be the best approach to create @2GP for the same? Please advise.
  • 1
    Code coverage is for the entire package, not just one class. Make sure you have all the files you need in your package repository.
    – sfdcfox
    Commented Jun 15, 2023 at 15:33
  • This org has only 1Apex class and VFpage which I retrieved from source in VS code. It has 100% coverage. what am I missing ?
    – SF Dev
    Commented Jun 16, 2023 at 4:16

1 Answer 1


How did you generate your package version? You need to use the -c attribute when generating your package version to calculate code coverage. https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_package_commands_unified.htm#cli_reference_package_version_create_unified

-c | --code-coverage Optional Calculate and store the code coverage percentage by running the packaged Apex tests included in this package version.

Before you can promote and release a managed or unlocked package version, the Apex code must meet a minimum 75% code coverage requirement. We don’t calculate code coverage for org-dependent unlocked packages or for package versions that specify --skip-validation.

  • I have used below commands for package creation : sfdx force:package:create --name "PackageName” --path force-app --packagetype Managed --targetdevhubusername sfdx force:package:version:create --name "GiveNameOfPackage” --installationkey GIVEKEY --wait 10 –v targetdevhubusername --codecoverage Sfdx force:package:version:promote –p PACKAGEVERSIONNAME -v TARGETDEVHUBUSERNAME
    – SF Dev
    Commented Jun 16, 2023 at 4:15
  • I used this command now - sf package version promote --package awesome_package_alias --target-dev-hub [email protected] , from the shared document link It started - Installing plugin packaging... - and was installed successfully after this I again got same error when I chose "y" for this Are you sure you want to release package version PACKAGE? You can't undo this action. Release package (y/n)?
    – SF Dev
    Commented Jun 16, 2023 at 4:41
  • @sfdcfox, Rob D - thank you for your suggestions I created a new project and did all steps from beginning, successfully created package. looks like my repository was not in sync as I added test class later. I am able to install the package in my personal devorg and other playgrounds
    – SF Dev
    Commented Jun 20, 2023 at 12:18
  • However, when I use the installation package URL to install on DEVORG for which I built this package with Namespace. It throws me this below error - "There are problems that prevent this package from being installed. Package and subscriber org namespace collision The installing package namespace and org namespace cannot be the same." My query is : What else is needed to install package in DEVORG where Namespace is created? OR Cant we install the package in the DEVORG where we defined namespace? Please advise, as I am doing it first time, I am bit confused.
    – SF Dev
    Commented Jun 20, 2023 at 12:18
  • Can someone guide and confirm, Which one should we use as destination(test org), where we can install the package created ? Should it be another Dev Org in PBO or any dev org(personal org) or new Test Org in PBO. looks like we need to share this destination org for security review. Please guide, I'm confused and stuck here
    – SF Dev
    Commented Jul 3, 2023 at 11:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .