From de8c7fd2d0e3bf3f8824a4d80be3832f6578b890 Mon Sep 17 00:00:00 2001 From: Esteban Romero Date: Tue, 16 Sep 2025 11:02:26 -0300 Subject: [PATCH 1/7] feat: add support for Agentforce agent tests --- messages/logicgettest.md | 2 +- messages/runlogictest.md | 14 +++++------ src/commands/logic/run/test.ts | 19 +++++++++++---- src/shared/TestRunService.ts | 17 +++++++++---- test/commands/logic/run/test.test.ts | 36 ++++++++++++++++++++++++---- 5 files changed, 66 insertions(+), 22 deletions(-) diff --git a/messages/logicgettest.md b/messages/logicgettest.md index 624efdfb..2f5c4f28 100644 --- a/messages/logicgettest.md +++ b/messages/logicgettest.md @@ -4,7 +4,7 @@ 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. diff --git a/messages/runlogictest.md b/messages/runlogictest.md index 59748621..7628a6bb 100644 --- a/messages/runlogictest.md +++ b/messages/runlogictest.md @@ -1,16 +1,16 @@ # 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. -To run specific tests, use the --tests flag, passing it the Apex test class names or the Flow tests in the form Flowtest.. 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 run specific tests, use the --tests flag, passing it the Apex test class names or the Flow tests in the form FlowTest. or Agentforce agents tests in the form AgentTest.. 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 agents 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. +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, 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. @@ -18,7 +18,7 @@ You must have the "View All Data" org system permission to use this command. The - Run a mix of specific Apex and Flow tests asynchronously in your default org: - <%= config.bin %> <%= command.id %> --tests MyApexClassTest,FlowTest.ProcessOrder + <%= config.bin %> <%= command.id %> --tests MyApexClassTest --tests FlowTest.ProcessOrder - Run all local Apex and Flow tests and wait for the results to complete; run the tests in the org with alias "my-scratch": @@ -34,8 +34,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. diff --git a/src/commands/logic/run/test.ts b/src/commands/logic/run/test.ts index c93bce51..d7ede8ad 100644 --- a/src/commands/logic/run/test.ts +++ b/src/commands/logic/run/test.ts @@ -1,8 +1,17 @@ /* - * Copyright (c) 2020, salesforce.com, inc. - * All rights reserved. - * Licensed under the BSD 3-Clause license. - * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + * Copyright 2025, Salesforce, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import { CancellationTokenSource } from '@salesforce/apex-node'; @@ -95,7 +104,7 @@ export default class RunTestLogic extends SfCommand { }), 'test-category': arrayWithDeprecation({ summary: messages.getMessage('flags.test-category.summary'), - options: ['Apex', 'Flow'], + options: ['Agent', 'Apex', 'Flow'], }), }; diff --git a/src/shared/TestRunService.ts b/src/shared/TestRunService.ts index 15da3d80..bcd4f3e0 100644 --- a/src/shared/TestRunService.ts +++ b/src/shared/TestRunService.ts @@ -1,8 +1,17 @@ /* - * Copyright (c) 2020, salesforce.com, inc. - * All rights reserved. - * Licensed under the BSD 3-Clause license. - * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + * Copyright 2025, Salesforce, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import { CancellationTokenSource, TestLevel, TestResult, TestRunIdResult, TestService } from '@salesforce/apex-node'; diff --git a/test/commands/logic/run/test.test.ts b/test/commands/logic/run/test.test.ts index b8695b84..f21e022d 100644 --- a/test/commands/logic/run/test.test.ts +++ b/test/commands/logic/run/test.test.ts @@ -1,8 +1,17 @@ /* - * Copyright (c) 2020, salesforce.com, inc. - * All rights reserved. - * Licensed under the BSD 3-Clause license. - * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + * Copyright 2025, Salesforce, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import fs from 'node:fs'; import { Messages, Org } from '@salesforce/core'; @@ -43,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', + 'test@user.com', + ]); + + 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([ @@ -91,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'); } }); From fbda5e0cf050987d3d2a7648efcef26c5c84a84b Mon Sep 17 00:00:00 2001 From: Juliet Shackell <63259011+jshackell-sfdc@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:27:04 -0700 Subject: [PATCH 2/7] Update logicgettest.md --- messages/logicgettest.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/messages/logicgettest.md b/messages/logicgettest.md index 2f5c4f28..5949fa0e 100644 --- a/messages/logicgettest.md +++ b/messages/logicgettest.md @@ -4,7 +4,7 @@ Get the results of a test run. # description -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. +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. @@ -12,11 +12,11 @@ To see code coverage results, use the --code-coverage flag with --result-format. - 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 + <%= config.bin %> <%= command.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 --result-format junit --target-org my-scratch + <%= config.bin %> <%= command.id %> --test-run-id --result-format junit --target-org my-scratch # flags.test-run-id.summary From 8b3967ffdfb336911dcf1049f353d637e5b47f64 Mon Sep 17 00:00:00 2001 From: Juliet Shackell <63259011+jshackell-sfdc@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:28:08 -0700 Subject: [PATCH 3/7] Update runlogictest.md --- messages/runlogictest.md | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/messages/runlogictest.md b/messages/runlogictest.md index efa557f1..bfc38ddb 100644 --- a/messages/runlogictest.md +++ b/messages/runlogictest.md @@ -1,26 +1,34 @@ # summary -Invoke tests for Apex, Flows and Agentforce agents 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, Flows and Agentforce agents. 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.". 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.". 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.". 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, 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 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": @@ -36,8 +44,8 @@ You must have the "View All Data" org system permission to use this command. The # flags.logicTests.summary -List of test names to run. Can include Apex test classes, Flow tests and Agentforce agent 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 Agent, Apex or Flow. +Category of tests to run, such as Agent, Apex, or Flow. From 8f6c759cb464d39a191d37d3d58c9c15a83fbfa2 Mon Sep 17 00:00:00 2001 From: svc-cli-bot Date: Wed, 17 Sep 2025 15:21:16 +0000 Subject: [PATCH 4/7] chore(release): 3.8.1-dev.0 [skip ci] --- README.md | 88 ++++++++++++++++++++++++++++++++-------------------- package.json | 2 +- 2 files changed, 55 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index e244b14f..d971c0ec 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ FLAG DESCRIPTIONS directory. ``` -_See code: [src/commands/apex/get/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.0/src/commands/apex/get/log.ts)_ +_See code: [src/commands/apex/get/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.1-dev.0/src/commands/apex/get/log.ts)_ ## `sf apex get test` @@ -210,7 +210,7 @@ EXAMPLES me@myorg' ``` -_See code: [src/commands/apex/get/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.0/src/commands/apex/get/test.ts)_ +_See code: [src/commands/apex/get/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.1-dev.0/src/commands/apex/get/test.ts)_ ## `sf apex list log` @@ -250,7 +250,7 @@ EXAMPLES $ sf apex list log --target-org me@my.org ``` -_See code: [src/commands/apex/list/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.0/src/commands/apex/list/log.ts)_ +_See code: [src/commands/apex/list/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.1-dev.0/src/commands/apex/list/log.ts)_ ## `sf apex run` @@ -297,7 +297,7 @@ EXAMPLES $ sf apex run ``` -_See code: [src/commands/apex/run.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.0/src/commands/apex/run.ts)_ +_See code: [src/commands/apex/run.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.1-dev.0/src/commands/apex/run.ts)_ ## `sf apex run test` @@ -443,7 +443,7 @@ FLAG DESCRIPTIONS --tests Test1 --tests Test2 ``` -_See code: [src/commands/apex/run/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.0/src/commands/apex/run/test.ts)_ +_See code: [src/commands/apex/run/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.1-dev.0/src/commands/apex/run/test.ts)_ ## `sf apex tail log` @@ -486,7 +486,7 @@ EXAMPLES $ sf apex tail log --color --skip-trace-flag ``` -_See code: [src/commands/apex/tail/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.0/src/commands/apex/tail/log.ts)_ +_See code: [src/commands/apex/tail/log.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.1-dev.0/src/commands/apex/tail/log.ts)_ ## `sf logic get test` @@ -516,8 +516,8 @@ GLOBAL FLAGS DESCRIPTION Get the results of a test run. - 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 @@ -526,25 +526,25 @@ DESCRIPTION EXAMPLES Get the results for a specific test run ID in the default human-readable format; uses your default org: - $ sf logic get test --test-run-id + $ sf logic get test --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": - $ sf logic get test --test-run-id --result-format junit --target-org my-scratch + $ sf logic get test --test-run-id --result-format junit --target-org my-scratch ``` -_See code: [src/commands/logic/get/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.0/src/commands/logic/get/test.ts)_ +_See code: [src/commands/logic/get/test.ts](https://github.com/salesforcecli/plugin-apex/blob/3.8.1-dev.0/src/commands/logic/get/test.ts)_ ## `sf logic run test` -Invoke tests for Apex and Flows in an org. +Invoke tests for Apex, Flows, and Agentforce agents in an org. ``` USAGE $ sf logic run test -o [--json] [--flags-dir ] [--api-version ] [-d ] [-l RunLocalTests|RunAllTestsInOrg|RunSpecifiedTests] [-n ... | -s ... | -t ... | --test-category - Apex|Flow...] [-r human|tap|junit|json] [-w ] [-y] [-v -c] [--concise] + Agent|Apex|Flow...] [-r human|tap|junit|json] [-w ] [-y] [-v -c] [--concise] FLAGS -c, --code-coverage Retrieve code coverage results. @@ -557,8 +557,8 @@ FLAGS -r, --result-format=