forcedotcom / cli

Salesforce CLI
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
BSD 3-Clause "New" or "Revised" License
490 stars 78 forks source link

sf apex run test : error - "Always provide a classes, suites, tests, or testLevel property" #2878

Closed OlegBogdanovych closed 4 months ago

OlegBogdanovych commented 4 months ago

Summary

In CI/CD after the metadata was deployed to scratch org when running apex tests it is error saying "Error (1): Always provide a classes, suites, tests, or testLevel property."

Command we are using to run apex unit tests is: sf apex run test -o $username -l RunLocalTests -c -r junit -w 90 -d ./tests/apex

Username is present because before running a tests I'm writing to debug a string with username variable, so it is always displaying like this: " APEX TESTS FOR test-ntsfcbjiiohi@example.com STARTED "

Actually if restart the pipeline several times it can start running apex unit tests, but there is no concrete number how many times pipeline should be restarted

Expected result

Apex unit tests execution started

Actual result

Error (1): Always provide a classes, suites, tests, or testLevel property.

System Information

Which shell or terminal are you using? - powershell

{
  "architecture": "win32-x64",
  "cliVersion": "@salesforce/cli/2.41.8",
  "nodeVersion": "node-v20.12.2",
  "osVersion": "Windows_NT 10.0.17763",
  "rootPath": "C:\\Windows\\System32\\config\\systemprofile\\AppData\\Local\\sf\\client\\2.41.8-dd2c629",
  "shell": "cmd.exe",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.0.17 (core)",
    "@oclif/plugin-commands 3.3.2 (core)",
    "@oclif/plugin-help 6.0.21 (core)",
    "@oclif/plugin-not-found 3.1.8 (core)",
    "@oclif/plugin-plugins 5.0.19 (core)",
    "@oclif/plugin-search 1.0.23 (core)",
    "@oclif/plugin-update 4.2.11 (core)",
    "@oclif/plugin-version 2.0.18 (core)",
    "@oclif/plugin-warn-if-update-available 3.0.16 (core)",
    "@oclif/plugin-which 3.1.9 (core)",
    "@salesforce/cli 2.41.8 (core)",
    "apex 3.1.11 (core)",
    "auth 3.6.9 (core)",
    "data 3.3.4 (core)",
    "deploy-retrieve 3.6.13 (core)",
    "info 3.2.7 (core)",
    "limits 3.3.5 (core)",
    "marketplace 1.2.5 (core)",
    "org 4.1.8 (core)",
    "packaging 2.4.2 (core)",
    "schema 3.3.6 (core)",
    "settings 2.2.6 (core)",
    "sobject 1.4.1 (core)",
    "source 3.3.9 (core)",
    "telemetry 3.3.5 (core)",
    "templates [56](https://gitlab.thelem-assurances.fr/thelem/salesforce/shiva/-/jobs/55195#L56).2.5 (core)",
    "trust 3.6.8 (core)",
    "user 3.5.5 (core)"
  ]
}
github-actions[bot] commented 4 months ago

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

iowillhoit commented 4 months ago

Hey @OlegBogdanovych, I tried to reproduce this with the Dreamhouse sample app and was not able to.

After creating the scratch org and deploying, I ran: sf apex run test -l RunLocalTests -c -r junit -w 90 -d ./tests/apex (I had my --target-org set to default at scratch org creation time)

Can you please provide the output of the same command with the --dev-debug flag?

iowillhoit commented 4 months ago

Also, if you are able to replicate the issue with Dreamhouse and provide steps, that would be very helpful. Thanks!

OlegBogdanovych commented 4 months ago

Hello @iowillhoit Looks like our issue was related to the runner - as soon as we did hard reload of sf plugins with this commands everything looks like fixed: sf plugins install @salesforce/plugin-packaging@latest sf plugins reset --reinstall --hard

I'll close this issue