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

fix: fixed error when running more than one test method from a same test class #321

Merged
merged 6 commits into from
Apr 20, 2023

Conversation

CristiCanizales
Copy link
Contributor

What does this PR do?

  • Makes it possible to run the specified tests in sfdx force:apex:test:run ...

What issues does this PR fix or reference?

#319 , @W-12436719@

Functionality Before

  • More than one test method from a same test class couldn't be ran

Functionality After

  • More than one test method from a same test class can be successfully ran

@CristiCanizales CristiCanizales marked this pull request as ready for review April 17, 2023 15:11
Copy link
Contributor

@klewis-sfdc klewis-sfdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, @CristiCanizales! Thank you for making the fix, and adding the test!

⚠️ One thing to note: I had to bump salesforce/core to "^3.34.6" to get this package to be on the same version of core as plugin-apex. Could you bump to that version in this branch? After that, if all is ✅ then we should be good to merge. Thank you!

QA looks good:
✅ sfdx force:apex:test:run now correctly runs two tests when specified in same test file, i.e. (this command now works when run against dreamhouse-lwc in a scratch org: sfdx force:apex:test:run -t "TestPropertyController.testGetPagedPropertyList,TestPropertyController.testGetPicturesNoResults")

Copy link
Contributor

@klewis-sfdc klewis-sfdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - thank you @CristiCanizales !!

:shipit:

@CristiCanizales CristiCanizales merged commit 4185599 into main Apr 20, 2023
@CristiCanizales CristiCanizales deleted the cristi/apex-test-run branch April 20, 2023 00:39
@vt89
Copy link

vt89 commented Apr 26, 2023

I am still facing this issue.

I have tried using both:
sfdx force:apex:test:run -u USERNAME -t "TestApexClass.testMethod1,TestApexClass.testMethod2,TestApexClass.testMethod3" -r human
and
sf apex run test --tests "TestApexClass.testMethod1,TestApexClass.testMethod2,TestApexClass.testMethod3" --result-format human

sfdx version: sfdx-cli/7.197.8 win32-x64 node-v18.15.0
sf version: @salesforce/cli/1.73.0 win32-x64 node-v18.15.0

@CristiCanizales
Copy link
Contributor Author

Hello @vt89 ! What error are you getting, the same one?

@vt89
Copy link

vt89 commented Apr 26, 2023

Hello @vt89 ! What error are you getting, the same one?

Hi @CristiCanizales
I am getting this error message:
Error (1): Include the class name TestApexClass only once.

@CristiCanizales
Copy link
Contributor Author

@vt89 Thank you for reaching out, thanks to that I just noticed the release workflow had failed and the change hadn't been published, but it's now. It should be @salesforce/apex-node v1.6.1

@vt89
Copy link

vt89 commented Apr 26, 2023

Hi @CristiCanizales
How can I get on my local machine your last change published?

@CristiCanizales
Copy link
Contributor Author

Hello @vt89! The fix should take effect this afternoon, when the CLI is updated. Please let me know if you continue getting the same error after you update yours.

@vt89
Copy link

vt89 commented Apr 28, 2023

Hello @CristiCanizales
SFDX and SF cli both updated but I still get the same error.

sfdx: sfdx-cli/7.198.7 win32-x64 node-v18.15.0
sf: @salesforce/cli/1.76.1 win32-x64 node-v18.15.0

@CristiCanizales
Copy link
Contributor Author

Hello @vt89 ! Sorry for all the waiting. The apex plugin hadn't been updated before that last release from the cli and that's why it's still failing. It has now been updated and the next release candidate for sfdx will be out this Thursday 4th, so you can wait until then and install the latest RC to test the change, or wait for the official release on May 11th.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants