sfdx force:apex:test:run

Invoke Apex tests


--jsonFormat output as JSON
--loglevel <loglevel>[default: warn] logging level for this command invocation; logs are stored in $HOME/.sfdx/sfdx.log
-u, --targetusername <targetusername>Username or alias for the target org; overrides default target org
--apiversion <apiversion>Override the api version used for api requests made by this command
-c, --codecoverageRetrieves code coverage results
-d, --outputdir <outputdir>Directory to store test run files
-l, --testlevel <testlevel>Specifies which tests to run, using one of these TestLevel enum values: RunSpecifiedTests—Only the tests that you specify are run. RunLocalTests—All tests in your org are run, except the ones that originate from installed managed packages. RunAllTestsInOrg—All tests are in your org and in installed managed packages are run
-n, --classnames <classnames>Comma-separated list of Apex test class names to run; if you select --classnames, you can't specify --suitenames or --tests
-r, --resultformat <resultformat>Permissible values are: human, tap, junit, json
-s, --suitenames <suitenames>Comma-separated list of Apex test suite names to run; if you select --suitenames, you can't specify --classnames or --tests
-t, --tests <tests>Comma-separated list of Apex test class names or IDs and, if applicable, test methods to run; if you specify --tests, you can't specify --classnames or --suitenames
-w, --wait <wait>Sets the streaming client socket timeout in minutes; specify a longer wait time if timeouts occur frequently
-y, --synchronousRuns test methods from a single Apex class synchronously; if not specified, tests are run ansynchronously
--verboseDisplay Apex test processing details; if JSON is specified, processing details aren't displayed
-v, --detailedcoverageDisplay detailed code coverage per test