+ Start a Discussion
Yogesh BiyaniYogesh Biyani 

install packages from VS code to production

I am trying to install https://github.com/ericrsmith35/Flow-PB-List-View-with-Batch-Delete using Deploy to Salesforce button in Production. However, this runs all tests and I am encountring some test failures in legacy code. While I will review the failures and fix it I believe there is a way to install packages from VS Code to production and run only specific tests related to this package. Where can I find detailed steps to do the same? 
Best Answer chosen by Yogesh Biyani
ShirishaShirisha (Salesforce Developers) 
Hi Yogesh,

Yes it works for the Production too but I would suggest you to try to validate it first and if that is successful then try the deployment directly.

Also,if you are familiar with any other tools to deploy then I would suggest you try with the RunspecifiedTests level with them as well.

Thank you!

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi Yogesh,

Greetings!

You can deploy the code by running Specific classes with ANT,Changeset and VS code too.

If you would like to proceed with the VS code/SFDX then you can use the below format to deploy the code using RunSpecifiedTests:


sfdx force:source:deploy -p "./PathToMetadata" -l RunSpecifiedTests -r TestClass1,TestClass2 -w 33 --verbose --loglevel fatal

This works if you have the list of the test classes in handy so that you can copy paste all the test classes separated by Comma(,).

Reference:https://salesforce.stackexchange.com/questions/266576/run-specific-apex-tests-during-sfdx-forcesourcedeploy

In Changset,you can use RunSpecifiedTests when trying to validate the code.

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Yogesh BiyaniYogesh Biyani
Hello Shirisha, Will this work for production too? I have never used VS Code to push changes to production. I have always updated the Sandbox and then either created a change set or an unmanaged package to update production. Yogesh
ShirishaShirisha (Salesforce Developers) 
Hi Yogesh,

Yes it works for the Production too but I would suggest you to try to validate it first and if that is successful then try the deployment directly.

Also,if you are familiar with any other tools to deploy then I would suggest you try with the RunspecifiedTests level with them as well.

Thank you!
This was selected as the best answer
Yogesh BiyaniYogesh Biyani
Hello Shirsha,

Thanks for the tips I was able to deploy the code. However I could not use -p as it was giving me an error saying the command can only be run from the project and it was also complaining about the sfdx-project.json file in the folder created after downloading the github zip. 

Here is what worked - 

sfdx force:source:deploy -x manifest/package.xml -l RunSpecifiedTests -r DeployDeleteInactiveFlowsTest,MetadataServiceTest,SObjectController2Test,TranslateFlowRecordsTest,GetFlowInfoAdvancedTest,ZippexTests,FlowDataTableDescriptorTest  -w 30 --verbose --loglevel fatal 


Thanks for all you help. 
Yogesh