Skip to content
Draft
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
6 changes: 3 additions & 3 deletions messages/logicgettest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ Get the results of a test run.

# description

When you run 'sf logic run test' to test Apex classes and Flows asynchronously, it returns a test run ID. Use that ID with this command to see the results.
When you run "sf logic run test" to test Apex classes, Flows, and Agentforce agents asynchronously, it returns a test run ID. Use that ID with this command to see the results.

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 classes in your org. If you specify human-readable result format, use the --detailed-coverage flag to see detailed coverage results for each test method run.

# examples

- Get the results for a specific test run ID in the default human-readable format; uses your default org:

<%= config.bin %> <%= command.id %> --test-run-id <test run id>
<%= config.bin %> <%= command.id %> --test-run-id <test-run-id>

- Get the results for a specific test run ID, format them as JUnit, and save them to the "test-results/junit" directory; uses the org with alias "my-scratch":

<%= config.bin %> <%= command.id %> --test-run-id <test run id> --result-format junit --target-org my-scratch
<%= config.bin %> <%= command.id %> --test-run-id <test-run-id> --result-format junit --target-org my-scratch

# flags.test-run-id.summary

Expand Down
28 changes: 18 additions & 10 deletions messages/runlogictest.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
# summary

Invoke tests for Apex and Flows in an org.
Invoke tests for Apex, Flows, and Agentforce agents in an org.

# description

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.
This command provides a single and unified way to run tests for multiple Salesforce features, such as Apex classes, Flows, and Agentforce agents. 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.
By default, the command executes asynchronously and returns a test run ID. Then use the displayed "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 and pass it the names of Apex and Flow tests. For Apex, simply specify the name of the Apex test class. For Flows, use the format "FlowTesting.<name-of-flow-test>". To find the name of all the flow tests in your org, run this command and specify the Flow category, such as "sf logic run test --synchronous --test-category Flow --test-level RunAllTestsInOrg". The command displays a table of all the flow tests it ran; see the "TEST NAME" column for the full name of all available flow tests in your org.
To run specific tests, use the --tests flag and pass it the names of Apex, Flow, and Agentforce agent tests. Here's how to find the name of each type of test:

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-category and --test-level together. If neither of these flags 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.
- For Apex, simply specify the name of the Apex test class.
- For Flows, use the format "FlowTesting.<name-of-flow-test>". To find the name of all the Flow tests in your org, run this command and specify the Flow category, such as "sf logic run test --synchronous --test-category Flow --test-level RunAllTestsInOrg". The command displays a table of all the Flow tests it ran; see the "TEST NAME" column for the full name of all available Flow tests in your org.
- For Agentforce agents, use the format "AgentTesting.<name-of-agent-test>". To find the names of all the Agentforce agent tests in your org, run the "sf agent test list" command. The command displays the available agent tests in the "API Name" column.

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 can also run specific test methods, although if you run the tests synchronously, the methods must belong to a single Apex class, Flow test, or Agentforce agent test. To run all tests of a certain category, use --test-category and --test-level together. If neither of these flags 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 Apex classes, Flows, or Agentforce agents. 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 Apex and Flow tests asynchronously in your default org:
- Run a specific Agentforce agent test asynchronously in your default org:

<%= config.bin %> <%= command.id %> --tests AgentTesting.Guest_Experience_Agent_Test

- Run a mix of specific Agentforce agent, Apex, and Flow tests asynchronously in your default org:

<%= config.bin %> <%= command.id %> --tests MyApexClassTest,FlowTesting.Modify_Account_Desc.Modify_Account_Desc_TestAccountDescription
<%= config.bin %> <%= command.id %> --tests AgentTesting.Guest_Experience_Agent_Test --tests MyApexClassTest --tests FlowTesting.Modify_Account_Desc.Modify_Account_Desc_TestAccountDescription

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

Expand All @@ -36,8 +44,8 @@ You must have the "View All Data" org system permission to use this command. The

# flags.logicTests.summary

Comma-separated list of test names to run. Can include Apex test classes and Flow tests.
List of test names to run. Can include Apex test classes, Flow tests, and Agentforce agent tests.

# flags.test-category.summary

Category of tests to run, such as Apex or Flow.
Category of tests to run, such as Agent, Apex, or Flow.
2 changes: 1 addition & 1 deletion src/commands/logic/run/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class RunTestLogic extends SfCommand<RunCommandResult> {
}),
'test-category': arrayWithDeprecation({
summary: messages.getMessage('flags.test-category.summary'),
options: ['Apex', 'Flow'],
options: ['Agent', 'Apex', 'Flow'],
}),
};

Expand Down
19 changes: 18 additions & 1 deletion test/commands/logic/run/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ describe('logic:test:run', () => {
});

describe('--test-category flag', () => {
it('should accept Agent as test category', async () => {
const testServiceStub = sandbox.stub(TestService.prototype, 'runTestAsynchronous').resolves(logicTestRunSimple);
await RunLogicTest.run([
'--test-category',
'Agent',
'--test-level',
'RunLocalTests',
'--target-org',
'[email protected]',
]);

expect(testServiceStub.calledOnce).to.be.true;
const testServiceCall = testServiceStub.getCall(0);
const testRunOptions = testServiceCall.args[0];

expect(testRunOptions.category).to.deep.equal(['Agent']);
});
it('should accept Apex as test category', async () => {
const testServiceStub = sandbox.stub(TestService.prototype, 'runTestAsynchronous').resolves(logicTestRunSimple);
await RunLogicTest.run([
Expand Down Expand Up @@ -100,7 +117,7 @@ describe('logic:test:run', () => {
]);
assert.fail('Expected command to throw an error for invalid test category');
} catch (error) {
expect((error as Error).message).to.include('Expected --test-category=Invalid to be one of: Apex, Flow');
expect((error as Error).message).to.include('Expected --test-category=Invalid to be one of: Agent, Apex, Flow');
}
});

Expand Down
Loading