Beta Package Version Creation Failing Due to Apex Test Outside Package Scope
- Dominant language
- No language data
- Stars
- 571
- Forks
- 80
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 3
Description
**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:
```json
{
"orgName": "Scratch Org",
"adminEmail": "",
"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
}
}
}
```
2. Ensure `MyProfilePageControllerTest` exists in the org.
3. Run the test class directly to confirm it fails:
```bash
sf apex run test --class-names MyProfilePageControllerTest --synchronous
```
6. 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).
---
Contributor guide
Assessment
This issue has not been assessed yet.