I'm looking to deploy my code using sfdx, these are the steps I'm going to take:

Retrieve code from sandbox:

sfdx force:source:retrieve -m MetadataType:ClassName,MetadataType:ClassName_Test -u YourSandboxOrgAlias

Deploy code to production:

sfdx force:source:deploy -m MetadataType:ClassName,MetadataType:ClassName_Test -l RunAllTests -r ClassName_Test -u YourProdOrgAlias

So I tried typing in the first command and pressed enter:

sfdx force:source:retrieve -m MetadataType:OnSiteActivityControllerTest.cls,MetadataType:OnSiteActivityController.cls -u Staging

but got 'No results found'.

enter image description here

Please advise.

Also, can you please review the steps above and let me know if they are syntactically correct?

  • Note in the 2nd code block, the -l RunAllTests will run all tests, and you don't need to specify the -r ClassName_Test. If you only want to run specific tests, used -l RunSpecifiedTests – Brian Miller Feb 25 '20 at 12:13
  • Thanks @BrianMiller, how can I run only the local tests? same as choosing 'Default' when deploying a change set – Json Feb 25 '20 at 12:37
  • nevermind found the answer, i should be RunLocalTests – Json Feb 25 '20 at 12:40

If you see the below command:-

sfdx force:source:retrieve -m MetadataType:OnSiteActivityControllerTest.cls,MetadataType:OnSiteActivityController.cls -u Staging

you have not defined the metadata type name. If you are retriving the apex class, the metadata name would be ApexClass, so the correct command would be:-

sfdx force:source:retrieve -m ApexClass:OnSiteActivityControllerTest,ApexClass:OnSiteActivityController -u Staging

Also, .cls extension is not required while retrieving.

Reference:- source:retrieve

  • Sweet, thank you! – Json Feb 25 '20 at 12:35

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.