I needed to validate that the deployment of some components would succeed. The deployment would be between two sandboxes of the same production org.

The components were two class/test class pairs that were already in the destination sandbox (i.e. only changes to the existing code were intended for deployment):


I wanted to use SFDX to validate. The first step I completed was to convert the items above from source to metadata format (although now it looks like there's no difference for classes).

I ran this command:

sfdx force:source:convert -d metadata/10282020INTDEPLOY \
-p force-app/main/default/classes/SetPaymentOpportunityFields.cls,\

That created these files:

enter image description here

Then I finally ran this command to perform the validation:

sfdx force:mdapi:deploy -u hsint -c \
-d metadata/10282020INTDEPLOY \
-l RunSpecifiedTests \
-r SetRequestOpportunityFieldsTest,RemoteTrxPaymentCtrlTest

But the validation Failed:

enter image description here

So I wanted to compare that SFDX validation attempt with a change-set validation.

I created a change set with the same components:

enter image description here

Then I ran validation on the change set with the same tests specified as my SFDX attempt (and which are the same tests in the deployment package):

enter image description here

And that validation succeeded:

enter image description here

So why the difference?

1 Answer 1


Because your changeset is different from what you prepared via SFDX.

Your changeset includes SetRequestOpportunityFields whereas your sfdx metadata directory includes SetPaymentOpportunityFields (for which you have no corresponding test class).

That there is your entire issue.


You don't need to do the conversion to metadata api form, as force:source:deploy has been able to deploy to sandboxes (and production) for several releases. The following should do what you want

sfdx force:source:deploy -u hsint -c -m ApexClass:SetRequestOpportunityFields,ApexClass:SetRequestOpportunityFieldsTest,ApexClass:RemoteTrxPaymentCtrl,ApexClass:RemoteTrxPaymentCtrlTest -l RunSpecifiedTests -r SetRequestOpportunityFieldsTest, RemoteTrxPaymentCtrlTest

the -m flag tells sfdx to only use the specified metadata in the deploy operation. Comma-separated list in <Metadata Type>:<API name> format.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .