diff --git a/messages/logicgettest.md b/messages/logicgettest.md index 624efdfb..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 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. @@ -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 diff --git a/messages/runlogictest.md b/messages/runlogictest.md index c9baff8f..bfc38ddb 100644 --- a/messages/runlogictest.md +++ b/messages/runlogictest.md @@ -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.". 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 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": @@ -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. diff --git a/src/commands/logic/run/test.ts b/src/commands/logic/run/test.ts index 7584f294..d7ede8ad 100644 --- a/src/commands/logic/run/test.ts +++ b/src/commands/logic/run/test.ts @@ -104,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/test/commands/logic/run/test.test.ts b/test/commands/logic/run/test.test.ts index 04483ec6..f21e022d 100644 --- a/test/commands/logic/run/test.test.ts +++ b/test/commands/logic/run/test.test.ts @@ -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', + '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([ @@ -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'); } });