We are trying to implement an pipeline on Azure to deploy our code to a sandbox. We would like to have a similar approach to what Change sets are doing.

For that we are thinking on deploy just what is specified by the developer on the package.xml At the same time we would like to run the test also specified by the developer on another file, where each test is separated by a comma.

It SFDX cli able to run the test that are set on a file?



This is possible with 2 ways and you need to give class names in comma separated values. I believe with pipeline some script(example - Shell) would be there so you can use those script to convert file value into variable and you can pass variable to command.

  1. you can use test classes with deployment commands like changeset -

Command - sfdx force:mdapi:deploy -d mdapiDeploy/unpackaged -l RunSpecifiedTests -r <class1,class2..classN> -u <userAlias> -w 5

Reference - https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_mdapi.htm

  1. If you are interested to know test as a individual entity, you can try below command -

sfdx force:apex:test:run -n "MyClassTest,MyOtherClassTest" -r human

Reference - https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_apex.htm#cli_reference_force_apex_test_run Referrence -

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.