[SalesForce] Run specific apex tests during “sfdx force:source:deploy”

Since summer 19, sfdx force:source:deploy allows us to push source format meta-data into static orgs and production. The Commands are introduced here

However when I check the help of sfdx force:source:deploy, it seems the lowest number of Apex tests that you can run is --testlevel RunLocalTests.

Is it possible to set it to run only specific apex tests when deploying into a production org?

Best Answer

Now with the latest sfdx update(7.21.0) you can run 'sfdx force:source:deploy' command with specific test classes. Check below command.

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

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