Skip to content

RunRelevantTests is not working #3565

@RaviVaranasi

Description

@RaviVaranasi

Summary

sf project deploy validate --test-level RunRelevantTests runs zero tests when the deployment payload contains an Apex class and its corresponding test class annotated with @istest(testFor='ApexClass:ClassName'), even though runTestsEnabled: true is returned in the deployment result. The validation succeeds without running any tests.

Steps To Reproduce

  1. Create a Salesforce project with sf project generate
  2. Add an Apex class (e.g. SampleService.cls)
  3. Add a corresponding test class annotated with @istest(testFor='ApexClass:SampleService'):
@IsTest(testFor='ApexClass:SampleService')
private class SampleServiceTest {
    @IsTest
    static void testExample() {
        // test logic here
    }
}
  1. Deploy the test class to the sandbox first to register the annotation in the org:
sf project deploy start \
  --source-file force-app/main/default/classes/SampleServiceTest.cls \
  --source-file force-app/main/default/classes/SampleServiceTest.cls-meta.xml \
  --target-org sandbox-alias \
  --test-level NoTestRun
  1. Make a change to SampleService.cls
  2. Generate a delta manifest using sfdx-git-delta:
sf sgd source delta \
  --from origin/main \
  --to HEAD \
  --source-dir force-app \
  --output-dir delta \
  --api-version 66.0
  1. Run validate with RunRelevantTests:
sf project deploy validate \
  --manifest delta/package/package.xml \
  --test-level RunRelevantTests \
  --target-org sandbox-alias \
  --wait 30 \
  --json
  1. The resulting package.xml contains both SampleService and SampleServiceTest as members.

Expected result

SampleServiceTest should be selected as a relevant test for SampleService based on the @IsTest(testFor='ApexClass:SampleService') annotation, and the test should run with code coverage enforced at 75%.

Actual result

Zero tests run. The deployment result shows:

"runTestResult": {
  "numFailures": 0,
  "numTestsRun": 0,
  "numTestsTotal": 0,
  "totalTime": 0,
  "successes": []
}

Despite "runTestsEnabled": true being present in the result. Full deployment result:

{
  "status": 0,
  "result": {
    "checkOnly": true,
    "details": {
      "runTestResult": {
        "numFailures": 0,
        "numTestsRun": 0,
        "numTestsTotal": 0,
        "totalTime": 0,
        "codeCoverage": [],
        "successes": []
      }
    },
    "numberTestsCompleted": 0,
    "numberTestsTotal": 0,
    "runTestsEnabled": true,
    "status": "Succeeded"
  }
}

Additional information

  • Org release: Summer '26 Patch 7.2 / API 67
  • sourceApiVersion in sfdx-project.json: 66.0
  • Both the production class and test class are in the delta manifest as ApexClass members
  • The @istest(testFor='ApexClass:SampleService') annotation was deployed to the org prior to running validate
  • The same payload run with --test-level RunLocalTests correctly runs tests and enforces coverage
  • This issue is specific to sf project deploy validate — behavior with sf project deploy start has not been verified to exhibit the same problem

System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.136.8",
  "nodeVersion": "node-v24.10.0",
  "osVersion": "Darwin 25.3.0",
  "rootPath": "/opt/homebrew/lib/node_modules/@salesforce/cli",
  "shell": "zsh",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.49 (core)",
    "@oclif/plugin-commands 4.1.54 (core)",
    "@oclif/plugin-help 6.2.49 (core)",
    "@oclif/plugin-not-found 3.2.86 (core)",
    "@oclif/plugin-plugins 5.4.68 (core)",
    "@oclif/plugin-search 1.2.49 (core)",
    "@oclif/plugin-update 4.7.40 (core)",
    "@oclif/plugin-version 2.2.46 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.65 (core)",
    "@oclif/plugin-which 3.2.54 (core)",
    "@salesforce/cli 2.136.8 (core)",
    "agent 1.40.3 (core)",
    "apex 3.9.29 (core)",
    "api 1.3.33 (core)",
    "auth 4.4.0 (core)",
    "code-analyzer 5.12.0 (user) published 32 days ago (Sun Apr 26 2026) (latest is 5.13.0)",
    "data 4.0.101 (core)",
    "deploy-retrieve 3.24.48 (core)",
    "info 3.4.133 (core)",
    "lightning-dev 6.2.17 (user) published 63 days ago (Fri Mar 27 2026)",
    "limits 3.3.89 (core)",
    "marketplace 1.3.26 (core)",
    "org 5.11.1 (core)",
    "packaging 2.27.9 (user) published 27 days ago (Sat May 02 2026) (latest is 2.28.3)",
    "schema 3.3.114 (core)",
    "settings 2.4.80 (core)",
    "sobject 1.4.108 (core)",
    "telemetry 3.8.21 (core)",
    "templates 56.17.2 (core)",
    "trust 3.8.9 (core)",
    "user 3.10.0 (core)",
    "@salesforce/sfdx-scanner 4.12.0 (user) published 395 days ago (Tue Apr 29 2025)",
    "apex-code-coverage-transformer 2.19.0 (user) published 27 days ago (Fri May 01 2026) (latest is 2.20.0)",
    "sf-git-merge-driver 1.8.0 (user) published 30 days ago (Wed Apr 29 2026) (latest is 1.9.0)",
    "sfdmu 5.6.4 (user) published 42 days ago (Thu Apr 16 2026)",
    "sfdx-git-delta 6.31.0 (user) published 105 days ago (Thu Feb 12 2026)",
    "sfdx-hardis 7.11.0 (user) published 32 days ago (Sun Apr 26 2026) (latest is 7.15.0)"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    investigatingWe're actively investigating this issuevalidatedVersion information for this issue has been validated

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions