1

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):

SetRequestOpportunityFields
SetRequestOpportunityFieldsTest
RemoteTrxPaymentCtrl
RemoteTrxPaymentCtrlTest

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,\
force-app/main/default/classes/SetRequestOpportunityFieldsTest.cls,\
force-app/main/default/classes/RemoteTrxPaymentCtrl.cls,\
force-app/main/default/classes/RemoteTrxPaymentCtrlTest.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?

3

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.

Bonus

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.

1

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.