Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Beta Package Version Creation Failing Due to Apex Test Outside Package Scope

Open
#3,540 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Domain
cli, release

Research direction

Start by reproducing the failure with the provided scratch-org definition and sf package version create, then run sf apex run test --class-names MyProfilePageControllerTest --synchronous to confirm the failing test. Investigate the create_package_version CI task and package-version test selection; done means beta creation is not blocked by the out-of-package MyProfilePageControllerTest failure.

Written by the indexing model from the issue text.

Description

owned by another team tracked elsewhere validated

Related to / reopening: #553

This issue was previously closed in #553 but we are still hitting the same behavior. Beta package version creation fails because Salesforce executes Apex tests that exist in the org but are not part of the package, causing the build to fail on tests we have no control over in the package context.


Description

When running sf package version create for a beta release, the command fails with an Apex Test Failure from a test class (MyProfilePageControllerTest) that is not included in the package source/branch. The test runner is picking up org-level tests beyond the package boundary, which makes the beta pipeline unreliable.

Error from CI logs:

[Error]: Package creation failed with error:
Apex Test Failure:
Class.element.MyProfilePageControllerTest.testSave: line 30,
column 1 System.AssertException: Assertion Failed
Exception in task create_package_version

Steps to Reproduce
  1. Create a scratch org using the following definition file:
{
  "orgName": "Scratch Org",
  "adminEmail": "<your-email>",
  "edition": "Developer",
  "features": ["EnableSetPasswordInApi", "Sites", "COMMUNITIES", "StateAndCountryPicklist"],
  "settings": {
    "apexSettings": {
      "enableDisableParallelApexTesting": false
    },
    "lightningExperienceSettings": {
      "enableS1DesktopEnabled": true
    },
    "mobileSettings": {
      "enableS1EncryptedStoragePref2": false
    },
    "experienceBundleSettings": {
      "enableExperienceBundleMetadata": true
    },
    "communitiesSettings": {
      "enableNetworksEnabled": true,
      "enableOotbProfExtUserOpsEnable": true
    },
    "customAddressFieldSettings": {
      "enableCustomAddressField": true
    },
    "externalClientAppSettings": {
      "enableClientSecretInRestApiAccess": true
    }
  }
}
  1. Ensure MyProfilePageControllerTest exists in the org.
  2. Run the test class directly to confirm it fails:
    sf apex run test --class-names MyProfilePageControllerTest --synchronous
    
  3. Observe the test fails due to MyProfilePageControllerTest.

Expected Behavior

Test should pass

Actual Behavior

The command fails with System.AssertException: Assertion Failed from MyProfilePageControllerTest.testSave (line 30).


Dominant language
No language data
Stars
571
Forks
80
Avg merge
2d 21h
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from forcedotcom/cli

All issues in forcedotcom/cli

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.