I wrote an Apex test (in the Developer console) for a method that is used in my LWC project. How do I upload it to my project in VSC?


All apex code, both production and tests, must appear in a "classes" folder in one of your "source" or "mdapi" structured projects.

On the assumption you're using a "source" structure and that you're using conventional organization where you have "force-app/main/default" as your directory structure, the Apex .cls file for the test should be put in "force-app/main/default/classes". This should mean it is in the same folder as the Apex class it is testing.

Performing an sfdx force:source:pull will drop this test class into the above folder structure if that's how you've configured the sfdx-project.json package directories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.