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

Create Apex Unit Test Class command overwrites existing files with no warning #5837

Open
pozil opened this issue Sep 11, 2024 · 7 comments
Open

Comments

@pozil
Copy link

pozil commented Sep 11, 2024

Summary

When running the Create Apex Unit Test Class command with a right click on the project tree or from the command palette and specifying a class name that already exists, the command overwrites the existing file content with no warning.

Steps To Reproduce:

  1. Create a Sample class and put some random code in there or a comment.
  2. Run the Create Apex Unit Test Class command and enter Sample for the class name
  3. Notice that the content of Sample.cls is replaced with the placeholder test code

Expected result

Command throws an error when file exists or prompts to confirm override

Actual result

Original file content is lost

Additional information

Salesforce Extension Version in VS Code:
Extension pack v61.12.0

Salesforce CLI Version:
@salesforce/cli/2.58.7 darwin-arm64 node-v18.17.0

OS and version:
macOs 14.6.1 (23G93)

VS Code version:
Version: 1.93.0 (Universal)
Commit: 4849ca9bdf9666755eb463db297b69e5385090e3
Date: 2024-09-04T13:02:38.431Z (1 wk ago)
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 23.6.0

@svc-idee-bot
Copy link
Collaborator

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.

@svc-idee-bot
Copy link
Collaborator

Hello @pozil 👋 It looks like you didn't provide all the required basic info in your issue.

If you haven't already, please provide the following info:
Salesforce Extension Version in VS Code:
Salesforce CLI Version:
OS and version:
VS Code version:
Most recent version of the extensions where this was working:

Here's an example of a set of required info that will pass the validation:
Salesforce Extension Version in VS Code: 60.13.0
Salesforce CLI Version: @salesforce/cli/2.42.6 darwin-arm64 node-v18.18.2
OS and version: MacOS Sonoma 14.5
VS Code version: 1.89.1
Most recent version of the extensions where this was working: 60.11.0

A few more things to check:

  • Make sure you've provided detailed steps to reproduce your issue, as well as all error messages that you see.
    • A repository that clearly demonstrates the bug is ideal.
    • Error messages can be found in the Problems Tab, Output Tab, and from running Developer: Toggle Developer Tools in the command palette.
  • Make sure you've installed the latest version of the Salesforce Extension Pack for VSCode. (docs)
  • Search GitHub for existing related issues.

Thank you!

@mingxuanzhangsfdx
Copy link
Member

Hi @pozil , when creating a apex unit test class with a duplicate name, are you able to see a prompt like this to confirm to overwrite the existing file?
image

@pozil
Copy link
Author

pozil commented Sep 11, 2024

Nope, as you can see:

2024-09-11.21-35-59.mp4

@diyer
Copy link
Collaborator

diyer commented Sep 12, 2024

Hi @pozil , we understand this is a bug (and we will consider fixing this) but as per Apex test naming conventions, the tests should have Test in their names as the suffix.

Copy link

git2gus bot commented Sep 12, 2024

This issue has been linked to a new work item: W-16736221

@pozil
Copy link
Author

pozil commented Sep 14, 2024

@diyer thanks. I know about the convention, I just made a silly copy/paste mistake and forgot to add the Test suffix. This is how I found the issue :)

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

4 participants