|
| 1 | +# Commands |
| 2 | + |
| 3 | +The available commands in the Apex plugin: |
| 4 | +<br /><br /> |
| 5 | + |
| 6 | +### `sfdx force:apex:log:get` |
| 7 | +fetch debug logs |
| 8 | +``` |
| 9 | +USAGE |
| 10 | + $ sfdx force:apex:log:get [-i <id>] [-n <number>] [-d <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel |
| 11 | + trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] |
| 12 | +
|
| 13 | +OPTIONS |
| 14 | + -d, --outputdir=outputdir |
| 15 | + directory for saving the log files |
| 16 | +
|
| 17 | + -i, --logid=logid |
| 18 | + id of the log to display |
| 19 | +
|
| 20 | + -n, --number=number |
| 21 | + number of most recent logs to display |
| 22 | +
|
| 23 | + -u, --targetusername=targetusername |
| 24 | + username or alias for the target org; overrides default target org |
| 25 | +
|
| 26 | + --apiversion=apiversion |
| 27 | + override the api version used for api requests made by this command |
| 28 | +
|
| 29 | + --json |
| 30 | + format output as JSON |
| 31 | +
|
| 32 | + --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) |
| 33 | + [default: warn] logging level for this command invocation |
| 34 | +
|
| 35 | +DESCRIPTION |
| 36 | + Fetches the specified log or given number of most recent logs from the scratch |
| 37 | + org. |
| 38 | + To get the IDs for your debug logs, run "sfdx force:apex:log:list". |
| 39 | + Use the --logid parameter to return a specific log. |
| 40 | + Use the --number parameter to return the specified number of recent logs. |
| 41 | + Use the --outputdir parameter to specify the directory to store the logs in. |
| 42 | + Executing this command without parameters returns the most recent log. |
| 43 | +
|
| 44 | +EXAMPLES |
| 45 | + $ sfdx force:apex:log:get -i <log id> |
| 46 | + $ sfdx force:apex:log:get -i <log id> -u me@my.org |
| 47 | + $ sfdx force:apex:log:get -n 2 -c |
| 48 | + $ sfdx force:apex:log:get -d Users/Desktop/logs -n 2 |
| 49 | +``` |
| 50 | +*See code: [force/apex/log/get.ts](https://github.com/forcedotcom/salesforcedx-apex/blob/develop/packages/plugin-apex/src/commands/force/apex/log/get.ts)* |
| 51 | +<br /><br /> |
| 52 | + |
| 53 | +### `sfdx force:apex:log:list` |
| 54 | +display a list of IDs and general information about debug logs |
| 55 | +``` |
| 56 | +USAGE |
| 57 | + $ sfdx force:apex:log:list [-u <string>] [--apiversion <string>] [--json] [--loglevel |
| 58 | + trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] |
| 59 | +
|
| 60 | +OPTIONS |
| 61 | + -u, --targetusername=targetusername |
| 62 | + username or alias for the target org; overrides default target org |
| 63 | +
|
| 64 | + --apiversion=apiversion |
| 65 | + override the api version used for api requests made by this command |
| 66 | +
|
| 67 | + --json |
| 68 | + format output as JSON |
| 69 | +
|
| 70 | + --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) |
| 71 | + [default: warn] logging level for this command invocation |
| 72 | +
|
| 73 | +DESCRIPTION |
| 74 | + Run this command in a project to list the IDs and general information for all debug logs |
| 75 | + in your default org. |
| 76 | + To fetch a specific log from your org, obtain the ID from this command's output, then run |
| 77 | + the “sfdx force:apex:log:get” command. |
| 78 | +
|
| 79 | +EXAMPLES |
| 80 | + $ sfdx force:apex:log:list |
| 81 | + $ sfdx force:apex:log:list -u me@my.org |
| 82 | +``` |
| 83 | +*See code: [force/apex/log/list.ts](https://github.com/forcedotcom/salesforcedx-apex/blob/develop/packages/plugin-apex/src/commands/force/apex/log/list.ts)* |
| 84 | +<br /><br /> |
| 85 | + |
| 86 | +### `sfdx force:apex:log:tail` |
| 87 | +ensures logging is active and returns the logs to the running user |
| 88 | + |
| 89 | +``` |
| 90 | +USAGE |
| 91 | + $ sfdx force:apex:log:list [-u <string>] [--apiversion <string>] [--json] [--loglevel |
| 92 | + trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] [-c] [-d <string>] [-s] |
| 93 | +
|
| 94 | +OPTIONS |
| 95 | + -u, --targetusername=targetusername |
| 96 | + username or alias for the target org; overrides default target org |
| 97 | +
|
| 98 | + --apiversion=apiversion |
| 99 | + override the api version used for api requests made by this command |
| 100 | +
|
| 101 | + --json |
| 102 | + format output as JSON |
| 103 | +
|
| 104 | + --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) |
| 105 | + [default: warn] logging level for this command invocation |
| 106 | +
|
| 107 | + -c, --color |
| 108 | + colorize noteworthy log lines |
| 109 | +
|
| 110 | + -d, --debuglevel=debuglevel |
| 111 | + debug level for trace flag |
| 112 | +
|
| 113 | + -s, --skiptraceflag |
| 114 | + skip trace flag setup |
| 115 | +
|
| 116 | +DESCRIPTION |
| 117 | + Activates debug logging and displays logs in the terminal. You can also pipe the logs to a file. |
| 118 | + To exit logging early, type Ctrl+C into the terminal. |
| 119 | +
|
| 120 | +EXAMPLES |
| 121 | + $ sfdx force:apex:log:tail |
| 122 | + $ sfdx force:apex:log:tail --debuglevel MyDebugLevel |
| 123 | + $ sfdx force:apex:log:tail -c -s |
| 124 | +``` |
| 125 | +*See code: [force/apex/log/tail.ts](https://github.com/forcedotcom/salesforcedx-apex/blob/develop/packages/plugin-apex/src/commands/force/apex/log/tail.ts)* |
| 126 | +<br /><br /> |
| 127 | + |
| 128 | +### `sfdx force:apex:execute` |
| 129 | +executes anonymous Apex code |
| 130 | +``` |
| 131 | +USAGE |
| 132 | + $ sfdx force:apex:execute [-f <filepath>] [-u <string>] [--apiversion <string>] [--json] |
| 133 | + [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] |
| 134 | +
|
| 135 | +OPTIONS |
| 136 | + -f, --apexcodefile=apexcodefile |
| 137 | + path to a local file that contains Apex code |
| 138 | +
|
| 139 | + -u, --targetusername=targetusername |
| 140 | + username or alias for the target org; overrides default target org |
| 141 | +
|
| 142 | + --apiversion=apiversion |
| 143 | + override the api version used for api requests made by this command |
| 144 | +
|
| 145 | + --json |
| 146 | + format output as json |
| 147 | +
|
| 148 | + --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) |
| 149 | + [default: warn] logging level for this command invocation |
| 150 | +
|
| 151 | +DESCRIPTION |
| 152 | + Executes one or more lines of anonymous Apex code entered on the command line, or executes |
| 153 | + the code in a local file. |
| 154 | + If you don’t run this command from within a Salesforce DX project, —-targetusername is |
| 155 | + required. |
| 156 | + To execute your code interactively, run this command with no parameters. At the prompt, |
| 157 | + enter all your Apex code; press CTRL-D when you're finished. Your code is then executed in |
| 158 | + a single execute anonymous request. |
| 159 | + For more information, see "Anonymous Blocks" in the Apex Developer Guide. |
| 160 | +
|
| 161 | +EXAMPLES |
| 162 | + $ sfdx force:apex:execute -u testusername@salesforce.org -f ~/test.apex |
| 163 | + $ sfdx force:apex:execute -f ~/test.apex |
| 164 | + $ sfdx force:apex:execute |
| 165 | + Start typing Apex code. Press the Enter key after each line, then press CTRL+D when |
| 166 | + finished. |
| 167 | +``` |
| 168 | +*See code: [force/apex/execute.ts](https://github.com/forcedotcom/salesforcedx-apex/blob/develop/packages/plugin-apex/src/commands/force/apex/execute.ts)* |
| 169 | +<br /><br /> |
| 170 | + |
| 171 | +### `sfdx force:apex:test:run` |
| 172 | +invoke Apex tests |
| 173 | +``` |
| 174 | +USAGE |
| 175 | + $ sfdx force:apex:test:run [-d <string>] [-l RunLocalTests|RunAllTestsInOrg|RunSpecifiedTests] [-n <string>] [-r human|tap|junit|json] |
| 176 | + [-s <string>] [-t <string>] [-w <string>] [-y] [-v -c] [-u <string>] [--apiversion <string>] [--verbose] [--json] |
| 177 | + [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] |
| 178 | +
|
| 179 | +OPTIONS |
| 180 | + -c, --codecoverage |
| 181 | + runs code coverage and retrieves results |
| 182 | +
|
| 183 | + -d, --outputdir=outputdir |
| 184 | + directory to store test run files |
| 185 | +
|
| 186 | + -l, --testlevel=(RunLocalTests|RunAllTestsInOrg|RunSpecifiedTests) |
| 187 | + specifies which tests to run, using one of these TestLevel enum values: |
| 188 | + RunSpecifiedTests—Only the tests that you specify are run. |
| 189 | + RunLocalTests—All tests in your org are run, except the ones that originate from |
| 190 | + installed managed packages. |
| 191 | + RunAllTestsInOrg—All tests are in your org and in installed managed packages are run |
| 192 | +
|
| 193 | + -n, --classnames=classnames |
| 194 | + comma-separated list of Apex test class names to run; if you select --classnames, you |
| 195 | + can't specify --suitenames or --tests |
| 196 | +
|
| 197 | + -r, --resultformat=(human|tap|junit|json) |
| 198 | + Permissible values are: human, tap, junit, json |
| 199 | +
|
| 200 | + -s, --suitenames=suitenames |
| 201 | + comma-separated list of Apex test suite names to run; if you select --suitenames, you |
| 202 | + can't specify --classnames or --tests |
| 203 | +
|
| 204 | + -t, --tests=tests |
| 205 | + comma-separated list of Apex test class names or IDs and, if applicable, test methods to |
| 206 | + run; if you specify --tests, you can't specify --classnames or --suitenames |
| 207 | +
|
| 208 | + -u, --targetusername=targetusername |
| 209 | + username or alias for the target org; overrides default target org |
| 210 | +
|
| 211 | + -v, --detailedcoverage |
| 212 | + display detailed code coverage per test |
| 213 | +
|
| 214 | + -w, --wait=wait |
| 215 | + sets the streaming client socket timeout in minutes; specify a longer wait time if timeouts occur |
| 216 | + frequently |
| 217 | +
|
| 218 | + -y, --synchronous |
| 219 | + runs test methods from a single Apex class synchronously; if not specified, tests are |
| 220 | + run ansynchronously |
| 221 | +
|
| 222 | + --apiversion=apiversion |
| 223 | + override the api version used for api requests made by this command |
| 224 | +
|
| 225 | + --json |
| 226 | + format output as JSON |
| 227 | +
|
| 228 | + --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) |
| 229 | + [default: warn] [default: warn] logging level for this command invocation; logs are |
| 230 | + stored in $HOME/.sfdx/sfdx.log |
| 231 | +
|
| 232 | + --verbose |
| 233 | + display Apex test processing details; if JSON is specified, processing details aren't |
| 234 | + displayed |
| 235 | +
|
| 236 | +DESCRIPTION |
| 237 | + Specify which tests to run by using the --classnames, --suites, or --tests parameters. |
| 238 | + Alternatively, use the --testlevel parameter to run all the tests in your org, local |
| 239 | + tests, or specified tests. |
| 240 | + To see code coverage results, use the --codecoverage parameter with --resultformat. The |
| 241 | + output displays a high-level summary of the test run and the code coverage values for |
| 242 | + classes in your org. If you specify human-readable result format, use the |
| 243 | + --detailedcoverage parameter to see detailed coverage results for each test method run. |
| 244 | + If --codecoverage is not included, code coverage will be skipped during the test run. |
| 245 | +
|
| 246 | + NOTE: The testRunCoverage value (JSON and JUnit result formats) is a percentage of the |
| 247 | + covered lines and total lines from all the Apex classes evaluated by the tests in this |
| 248 | + run. |
| 249 | +
|
| 250 | +EXAMPLES |
| 251 | + $ sfdx force:apex:test:run |
| 252 | + $ sfdx force:apex:test:run -n "MyClassTest,MyOtherClassTest" -r human |
| 253 | + $ sfdx force:apex:test:run -s "MySuite,MyOtherSuite" -c -v --json |
| 254 | + $ sfdx force:apex:test:run -t |
| 255 | + "MyClassTest.testCoolFeature,MyClassTest.testAwesomeFeature,AnotherClassTest,namespace.TheirClassTest.testThis" -r human |
| 256 | + $ sfdx force:apex:test:run -l RunLocalTests -d <path to outputdir> -u me@my.org |
| 257 | +``` |
| 258 | +*See code: [force/apex/test/run.ts](https://github.com/forcedotcom/salesforcedx-apex/blob/develop/packages/plugin-apex/src/commands/force/apex/test/run.ts)* |
| 259 | +<br /><br /> |
| 260 | + |
| 261 | +### `sfdx force:apex:test:report` |
| 262 | +display test results for a specific asynchronous test run |
| 263 | +``` |
| 264 | +USAGE |
| 265 | + $ sfdx force:apex:test:report -i <string> [-c] [-d <string>] [-r human|tap|junit|json] [-w <string>] |
| 266 | + [-u <string>] [--apiversion <string>] [--verbose] [--json] [--loglevel |
| 267 | + trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] |
| 268 | +
|
| 269 | +OPTIONS |
| 270 | + -c, --codecoverage |
| 271 | + retrieves code coverage results |
| 272 | +
|
| 273 | + -d, --outputdir=outputdir |
| 274 | + directory to store test result files |
| 275 | +
|
| 276 | + -i, --testrunid=testrunid |
| 277 | + (required) the ID of the test run |
| 278 | +
|
| 279 | + -r, --resultformat=(human|tap|junit|json) |
| 280 | + Permissible values are: human, tap, junit, json |
| 281 | +
|
| 282 | + -u, --targetusername=targetusername |
| 283 | + username or alias for the target org; overrides default target org |
| 284 | +
|
| 285 | + -w, --wait=wait |
| 286 | + sets the streaming client socket timeout in minutes; specify a longer wait time if timeouts occur |
| 287 | + frequently |
| 288 | +
|
| 289 | + --apiversion=apiversion |
| 290 | + override the api version used for api requests made by this command |
| 291 | +
|
| 292 | + --json |
| 293 | + format output as JSON |
| 294 | +
|
| 295 | + --loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) |
| 296 | + [default: warn] [default: warn] logging level for this command invocation; logs are |
| 297 | + stored in $HOME/.sfdx/sfdx.log |
| 298 | +
|
| 299 | + --verbose |
| 300 | + display Apex test processing details; if JSON is specified, processing details aren't |
| 301 | + displayed |
| 302 | +
|
| 303 | +DESCRIPTION |
| 304 | + Provide a test run ID to display test results for an enqueued or completed asynchronous |
| 305 | + test run. The test run ID is displayed after running the "sfdx force:apex:test:run" |
| 306 | + command. |
| 307 | +
|
| 308 | +EXAMPLES |
| 309 | + $ sfdx force:apex:test:report -i <test run id> |
| 310 | + $ sfdx force:apex:test:report -i <test run id> -r junit |
| 311 | + $ sfdx force:apex:test:report -i <test run id> -c --json |
| 312 | + $ sfdx force:apex:test:report -i <test run id> -c -d <path to outputdir> -u me@myorg |
| 313 | +``` |
| 314 | +*See code: [force/apex/test/report.ts](https://github.com/forcedotcom/salesforcedx-apex/blob/develop/packages/plugin-apex/src/commands/force/apex/test/report.ts)* |
0 commit comments