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

sfdx force:apex:test:run fails when run from Github action #306

Open
leighgreen-access opened this issue Apr 4, 2022 · 6 comments
Open

Comments

@leighgreen-access
Copy link

leighgreen-access commented Apr 4, 2022

Summary

When we run sfdx force:apex:test:run from our ci/cd Github action, it fails with the error "ERROR running force:apex:test:run: Always provide a classes, suites, tests, or testLevel property."

Steps To Reproduce:

Repository to reproduce: dreamhouse-lwc

We are using code based on the scratch-org-test job of ci-pr.yml in the dreamhouse repo.

  1. Install Salesforce CLI
  2. Checkout the source code
  3. Store secret for dev hub
  4. Authenticate dev hub
  5. Create scratch org
  6. Deploy source to scratch org
  7. Assign permissionset
  8. SKIPPED Import sample data
  9. Run Apex tests in scratch org

Expected result

Test suite is run

Actual result

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

We have tried adding a -l RunAllTestsInOrg switch (also tried RunLocalTests, and using --testlevel) and still get the same error.

System Information

Output after installing the sfdx-cli -
sfdx-cli/7.144.2 linux-x64 node-v16.14.2

This was previously working with v7.143.0

@github-actions
Copy link

github-actions bot commented Apr 4, 2022

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.

@WillieRuemmele WillieRuemmele transferred this issue from forcedotcom/cli Apr 4, 2022
@leighgreen-access
Copy link
Author

I'm not sure why this was moved from cli to the -vscode repo, it has nothing to do with the VS Code extension.

@db-lyon
Copy link

db-lyon commented May 2, 2022

I'm experiencing this issue across all of our sfdx projects in Github Actions.

Most definitely not a VS Code extension issue.

@jeffhube
Copy link

jeffhube commented Jul 6, 2022

I am occasionally encountering this in a custom CI process. Following a successful sfdx force:source:push, I call the Salesforce REST API directly to run unit tests. I agree that this is not a VS Code extension issue, and possibly not an sfdx-cli issue, either.

I'm POSTing to /services/data/v43.0/tooling/runTestsAsynchronous with a testLevel of RunLocalTests and a skipCodeCoverage of true. The response errorCode is INVALID_INPUT and the message is Always provide a classes, suites, tests, or testLevel property.

@randi274 randi274 transferred this issue from forcedotcom/salesforcedx-vscode Nov 7, 2022
@RupertBarrow
Copy link

I'm also getting "return code: 1" when running sfdx force:apex:test:run --testlevel=RunLocalTests --outputdir=/tmp --codecoverage --resultformat=human from Github Actions :

903      Running task: dx                                            
904      ------------------------------------------------------------
905                                                                  
906      Options:                                                    
907        command: force:apex:test:run --testlevel=RunLocalTests    
908      --outputdir=/tmp --codecoverage --resultformat=human        
909
[01/10/23 10:43:46] Beginning task: SFDXOrgTask                                 
910                                                                  
911      Running command: sfdx force:apex:test:run                   
912      --testlevel=RunLocalTests --outputdir=/tmp --codecoverage   
913      --resultformat=human -u [email protected]       
914
[01/10/23 10:43:50] Return code: 1                                              
915      stderr: WARNING: WARNING: In the Summer ’21 release, we'll  
916      rename or remove some of the output files that are created  
917      when you run force:apex:test:run or force:apex:test:report  
918      with the --outputdir (-d) parameter.  This breaking change  
919      could impact your CI/CD scripts if they reference specific  
920      filenames. See https://sfdc.co/apex-test-updates for details
921                                                                  
922      ERROR running force:apex:test:run:  Toujours fournir une    
923      propriété classes, suites, tests ou testLevel.              
924                                                                  
925
Error: Return code: 1
926
stderr: WARNING: WARNING: In the Summer ’21 release, we'll rename or remove some
of the output files that are created when you run force:apex:test:run or 
force:apex:test:report with the --outputdir (-d) parameter.  This breaking 
change could impact your CI/CD scripts if they reference specific filenames. See
https://sfdc.co/apex-test-updates for details

932
ERROR running force:apex:test:run:  Toujours fournir une propriété classes, 
suites, tests ou testLevel.

Run this command for more information about debugging errors: cci error --help
936      Exception in task dx                                        

Error: Process completed with exit code 1.

@harditsingh
Copy link

I just ran into this issue, took me a day to figure out that if there are no Apex classes in the org that you are attempting to run the code in, the sfdx force:apex:test:run command fails with the error Always provide a classes, suites, tests, or testLevel property.. Wondering if it would be helpful to have a different error message when there is no apex code in the org?

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

6 participants