Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions messages/runlogictest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,46 @@ Invoke tests for Apex and Flows in an org.

# description

This command provides a single, unified interface to run tests for multiple metadata types.
By default, the command executes asynchronously, returning a test run ID. Use 'sf logic get test' to retrieve the results.
Use the --synchronous flag to wait for the test run to complete and see the results in the command output.
To run specific tests, use --test-names. To run all tests of a certain type, use --test-level with --test-category. If neither is specified, all local tests for all categories will be run.
This command provides a single and unified way to run tests for multiple Salesforce features, such as Apex classes and Flows. Running the tests together with a single command ensures seamless interoperability between the features.

By default, the command executes asynchronously and returns a test run ID. Then use the "sf logic get test" command to retrieve the results. If you want to wait for the test run to complete and see the results in the command output, use the --synchronous flag.

To run specific tests, use the --tests flag, passing it the Apex test class names or the Flow tests in the form Flowtest.<name>. You can also run specific test methods, although if you run the tests synchronously, the methods must belong to a single Apex class or Flow test. To run all tests of a certain category, use --test-level with --test-category. If neither flag is specified, all local tests for all categories are run by default. You can also use the --class-names and --suite-names flags to run Apex test classes or suites.

To see code coverage results, use the --code-coverage flag with --result-format. The output displays a high-level summary of the test run and the code coverage values for the tested classes or flows. If you specify human-readable result format, use the --detailed-coverage flag to see detailed coverage results for each test method run.

You must have the "View All Data" org system permission to use this command. The permission is disabled by default and can be enabled only by a system administrator.

# examples

- Run a mix of specific named tests for Apex and Flow asynchronously:
- Run a mix of specific Apex and Flow tests asynchronously in your default org:

<%= config.bin %> <%= command.id %> --test-names MyApexClassTest,FlowTest.ProcessOrder
<%= config.bin %> <%= command.id %> --tests MyApexClassTest,FlowTest.ProcessOrder

- Run all local tests for only the Apex and Flow categories, waiting for the results to complete:
- Run all local Apex and Flow tests and wait for the results to complete; run the tests in the org with alias "my-scratch":

<%= config.bin %> <%= command.id %> --test-level RunLocalTests --test-category Apex --test-category Flow --synchronous
<%= config.bin %> <%= command.id %> --test-level RunLocalTests --test-category Apex --test-category Flow --synchronous --target-org my-scratch

- Run all local tests for ALL categories (the default behavior) and save the JUnit results to the "test-results" directory:
- Run two methods in an Apex test class and an Apex test suite:

<%= config.bin %> <%= command.id %> --result-format junit --output-dir test-results --synchronous
<%= config.bin %> <%= command.id %> --class-names MyApexClassTest.methodA --class-names MyApexClassTest.methodB --suite-names MySuite

- Run all local tests for all categories (the default behavior), save the JUnit results to the "test-results" directory, and include code coverage results:

<%= config.bin %> <%= command.id %> --result-format junit --output-dir test-results --synchronous --code-coverage

# flags.logicTests.summary

Comma-separated list of test names to run. Can include Apex classes, Flow tests (FlowTest.<name>), and Agent tests (AgentTest.<name>).
Comma-separated list of test names to run. Can include Apex test classes and Flow tests.

# flags.test-category.summary

Category of tests to run.
Category of tests to run, such as Apex or Flow.

# flags.test-category.description
# runLogicTestReportCommand

Category of tests to run. Can be specified multiple times. Valid values are 'Apex' and 'Flow'.
Run "%s logic get test -i %s -o %s" to retrieve the test results.

# runLogicTestReportCommand
# runTestSyncInstructions

Run "%s logic get test -i %s -o %s" to retrieve test results
Run with --synchronous or increase --wait timeout to wait for results.
43 changes: 43 additions & 0 deletions messages/runtest.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ To see code coverage results, use the --code-coverage flag with --result-format.

By default, Apex tests run asynchronously and immediately return a test run ID. You can use the --wait flag to specify the number of minutes to wait; if the tests finish in that timeframe, the command displays the results. If the tests haven't finished by the end of the wait time, the command displays a test run ID. Use the "<%= config.bin %> apex get test --test-run-id" command to get the results.

To run both Apex and Flow tests together, run the "sf logic run test" CLI command, which has similar flags as this command, but expands the --tests flag to also include Flow tests.

You must have the "View All Data" system permission to use this command. The permission is disabled by default and can be enabled only by a system administrator.

NOTE: The testRunCoverage value (JSON and JUnit result formats) is a percentage of the covered lines and total lines from all the Apex classes evaluated by the tests in this run.
Expand Down Expand Up @@ -125,3 +127,44 @@ Display detailed code coverage per test.
# flags.concise.summary

Display only failed test results; works with human-readable output only.

# runTestReportCommand

Run "%s apex get test -i %s -o %s" to retrieve test results

# runLogicTestReportCommand

Run "%s logic get test -i %s -o %s" to retrieve test results

# runTestSyncInstructions

Run with --synchronous or increase --wait timeout to wait for results.

# syncClassErr

Synchronous test runs can include test methods from only one Apex class. Omit the --synchronous flag or include tests from only one class.

# syncClassErrForUnifiedLogic

Synchronous test runs can include test methods from either a single Apex class or a single Flow test. Omit the --synchronous flag or include test methods from only one class or Flow.

# testLevelErr

When specifying classnames, suitenames, or tests, indicate RunSpecifiedTests as the testlevel

# testResultProcessErr

Encountered an error when processing test results
%s

# apexTestReportFormatHint

Run "sf apex get test %s --result-format <format>" to retrieve test results in a different format.

# outputDirHint

Test result files written to %s

# apexLibErr

Unknown error in Apex Library: %s
Loading