Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Always provide a classes, suites, tests, or testLevel property." when running sfdx force:apex:test:run -l RunLocalTests on a project with no tests #282

Open
fransf-wtax opened this issue Oct 25, 2021 · 7 comments

Comments

@fransf-wtax
Copy link

fransf-wtax commented Oct 25, 2021

Summary

SFDX exits with the following error when running sfdx force:apex:test:run -l RunLocalTests on a project with no tests:

ERROR running force:apex:test:run: Always provide a classes, suites, tests, or testLevel property.

Since -l sets the testLevel property, the error message is wrong (testLevel was provided). In the case where there are no local tests and RunLocalTests is set as test level, the call should just complete without doing anything.

Steps To Reproduce:

  1. Run sfdx force:apex:test:run -l RunLocalTests in a DX project that has no tests, with the scratch org already created and set as the default username.

Expected result

All local tests are run (which is no tests in an org with no local tests).

Actual result

ERROR running force:apex:test:run:  Always provide a classes, suites, tests, or testLevel property.

error is returned.

System Information

{
	"cliVersion": "sfdx-cli/7.123.0",
	"architecture": "darwin-x64",
	"nodeVersion": "node-v14.18.1",
	"pluginVersions": [
		"@assisisolutions/sfdx-ci-plugin 1.0.1",
		"@oclif/plugin-autocomplete 0.3.0 (core)",
		"@oclif/plugin-commands 1.3.0 (core)",
		"@oclif/plugin-help 3.2.3 (core)",
		"@oclif/plugin-not-found 1.2.4 (core)",
		"@oclif/plugin-plugins 1.10.1 (core)",
		"@oclif/plugin-update 1.5.0 (core)",
		"@oclif/plugin-warn-if-update-available 1.7.0 (core)",
		"@oclif/plugin-which 1.0.3 (core)",
		"alias 1.1.22 (core)",
		"auth 1.7.3 (core)",
		"config 1.2.41 (core)",
		"generator 1.2.0 (core)",
		"salesforcedx 52.0.0",
		"├─ data 0.4.11",
		"├─ apex 0.2.2",
		"├─ schema 1.0.7",
		"├─ custom-metadata 1.0.12",
		"├─ templates 51.5.0",
		"├─ org 1.6.6",
		"├─ limits 1.2.1",
		"├─ user 1.3.0",
		"├─ salesforce-alm 52.0.0",
		"└─ @salesforce/sfdx-plugin-lwc-test 0.1.7",
		"sfdx-cli 7.123.0 (core)",
		"source 1.2.4 (core)",
		"telemetry 1.2.8 (core)",
		"texei-sfdx-plugin 1.11.1",
		"trust 1.0.8 (core)"
	],
	"osVersion": "Darwin 19.6.0"
}

Additional information

N/A

@github-actions
Copy link

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.

@mshanemc
Copy link
Contributor

please uninstall the salesforcedx plugin and try again. That makes a bunch of your CLI commands, including apex, out of date by months.

sfdx plugins:uninstall salesforcedx

@fransf-wtax
Copy link
Author

OK, tried that but the result is the same.

However, I think the problem might be that the org I'm testing against has no local tests. So it might be a case of needing a clearer error message -- or just accepting the fact that in an org with no tests, running all local tests means running no tests, which is absolutely fine: if I ask you to give me all your Ferraris and you give me zero, that's probably because you don't have any Ferraris ;-)

I'll update the issue title and description.

@fransf-wtax fransf-wtax changed the title "Always provide a classes, suites, tests, or testLevel property." when running sfdx force:apex:test:run -l RunLocalTests "Always provide a classes, suites, tests, or testLevel property." when running sfdx force:apex:test:run -l RunLocalTests on a project with no tests Oct 25, 2021
@WillieRuemmele
Copy link
Member

I'm transferring to the repo that tracks issues for all apex:* commands

@WillieRuemmele WillieRuemmele transferred this issue from forcedotcom/cli Oct 25, 2021
@randi274
Copy link
Contributor

@fransf-wtax I was able to reproduce the error message, but can you provide us a little more detail as to why you would be running this command in an org without tests? (If I omit the -l parameter, I still encounter the issue!). That will help us figure out prioritizing this issue. I also am not finding this error in any of our extension or libraries, so I think this might be something that we're getting back upstream from Salesforce proper.

@fransf-wtax
Copy link
Author

@randi274 Well in this case I thought the org had tests but it didn't. But the error message tells me I did something wrong on the command line (I didn't specify a test level, test suite, or list of tests) when in fact the "error", if you want to call it that, was that there were no (local) tests on the org. A good error message not only tells the user what's wrong, but also gives some indication as to how to fix it.

So I think it just avoids confusion when you tell the user what the actual problem is instead of confusing them by saying they need to specify a test level when they did specify a test level.

If I say rm bla on the command line, I get an error that says rm: bla: No such file or directory. It doesn't say rm: You have to specify a file to unlink. So I think it's reasonable to expect the same from the Salesforce CLI.

Hope this helps!

@randi274
Copy link
Contributor

Thanks for the additional information @fransf-wtax! @smaddox-sf this would be a product question on how we should handle it - this is an error message that we get back from core, so we could provide a check for orgs without tests, handle the error message more politely, or leave it as-is as a somewhat confusing message.

@randi274 randi274 transferred this issue from forcedotcom/salesforcedx-vscode Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants