function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DbjensenDbjensen 

How to run local tests with Microsoft visual studio?

Hello - I need to deploy a class to a sandbox and need to run local tests. How can I run local tests using Microsoft Visual Studio? 

User-added image

 
Best Answer chosen by Dbjensen
Vishwajeet kumarVishwajeet kumar
Hello,
If you have salesforce extension intalled in VS code, sfdx command in CLI can be used for it. Look into CLI commands doc here (https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm).

Example : Deploy apex class by running local tests.
    $ sfdx force:source:deploy -m ApexClass -l RunLocalTests


Thanks

All Answers

Vishwajeet kumarVishwajeet kumar
Hello,
If you have salesforce extension intalled in VS code, sfdx command in CLI can be used for it. Look into CLI commands doc here (https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm).

Example : Deploy apex class by running local tests.
    $ sfdx force:source:deploy -m ApexClass -l RunLocalTests


Thanks
This was selected as the best answer
ANUTEJANUTEJ (Salesforce Developers) 
Hi Dbjensen,

>> https://trailhead.salesforce.com/en/content/learn/v/projects/find-and-fix-bugs-with-apex-replay-debugger/apex-replay-debugger-debug-your-code#:~:text=the%20previous%20step.-,Run%20Apex%20Tests,Choose%20AccountServiceTest.

This module regarding "Replay debug logs in Visual Studio Code to discover the root cause of errors in your code." could help you in this regards as it has a step by step process that you can follow.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
DbjensenDbjensen
Hi Vishwajeet - This wroked perfectly. Thanks so much. 

Hi Anutej - thanks for the helpful doc. Very good info.