$npx -y skills add SalesforceAIResearch/agentforce-adlc --skill agentforce-testWrite, run, and analyze structured test suites for Agentforce agents. TRIGGER when: user writes or modifies test spec YAML (AiEvaluationDefinition); runs sf agent test create, run, run-eval, or results commands; asks about test coverage strategy, metric selection, or custom evalu
| 1 | # ADLC Test |
| 2 | |
| 3 | Automated testing for Agentforce agents with smoke tests, batch execution, and iterative fix loops. |
| 4 | |
| 5 | ## Overview |
| 6 | |
| 7 | This skill provides comprehensive testing capabilities for Agentforce agents, including automated utterance derivation from agent subagents, preview-based smoke testing, trace analysis, and an iterative fix loop for identified issues. It bridges the gap between initial development and production deployment. |
| 8 | |
| 9 | ## Platform Notes |
| 10 | |
| 11 | - Shell examples below use bash syntax. On Windows, use PowerShell equivalents or Git Bash. |
| 12 | - Replace `python3` with `python` on Windows. |
| 13 | - Replace `/tmp/` with `$env:TEMP\` (PowerShell) or `%TEMP%\` (cmd). |
| 14 | - Replace `jq` with `python -c "import json,sys; ..."` if jq is not installed. |
| 15 | - `find ... | head -1` -> `Get-ChildItem -Recurse ... | Select-Object -First 1` in PowerShell. |
| 16 | |
| 17 | ## Usage |
| 18 | |
| 19 | This skill uses `sf agent preview` and `sf agent test` CLI commands directly. |
| 20 | There is no standalone Python script. |
| 21 | |
| 22 | **Quick smoke test (Mode A):** |
| 23 | ```bash |
| 24 | # Start preview, send utterance, end session (--authoring-bundle generates local traces) |
| 25 | sf agent preview start --json --authoring-bundle MyAgent -o <org-alias> |
| 26 | sf agent preview send --json --session-id <ID> --utterance "test" --authoring-bundle MyAgent -o <org-alias> |
| 27 | sf agent preview end --json --session-id <ID> --authoring-bundle MyAgent -o <org-alias> |
| 28 | ``` |
| 29 | |
| 30 | **Batch testing (Mode B):** |
| 31 | ```bash |
| 32 | # Deploy and run test suite |
| 33 | sf agent test create --json --spec test-spec.yaml --api-name MySuite -o <org-alias> |
| 34 | sf agent test run --json --api-name MySuite --wait 10 --result-format json -o <org-alias> |
| 35 | ``` |
| 36 | |
| 37 | **Action execution:** |
| 38 | ```bash |
| 39 | # Execute a Flow or Apex action directly via REST API |
| 40 | TOKEN=$(sf org display -o <org-alias> --json | jq -r '.result.accessToken') |
| 41 | INSTANCE_URL=$(sf org display -o <org-alias> --json | jq -r '.result.instanceUrl') |
| 42 | curl -s "$INSTANCE_URL/services/data/v63.0/actions/custom/flow/Get_Order_Status" \ |
| 43 | -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ |
| 44 | -d '{"inputs": [{"orderId": "00190000023XXXX"}]}' |
| 45 | ``` |
| 46 | |
| 47 | ## Testing Workflow |
| 48 | |
| 49 | This skill supports two testing modes plus direct action execution: |
| 50 | |
| 51 | - **Mode A: Ad-Hoc Preview Testing** -- Quick smoke tests during development using `sf agent preview`. No test suite deployment needed (org authentication still required). Best for iterative development and fix validation. |
| 52 | - **Mode B: Testing Center Batch Testing** -- Persistent test suites deployed to the org via `sf agent test`. Best for regression suites, CI/CD, and cross-skill integration with /agentforce-observe. |
| 53 | - **Action Execution** -- Direct invocation of Flow/Apex actions via REST API for isolated testing and debugging. |
| 54 | |
| 55 | **When to use which:** |
| 56 | |
| 57 | | Scenario | Mode | |
| 58 | |----------|------| |
| 59 | | Quick smoke test during authoring | Mode A | |
| 60 | | Validate a fix from /agentforce-observe | Mode A | |
| 61 | | Build a regression suite for CI/CD | Mode B | |
| 62 | | Deploy tests to share with the team | Mode B | |
| 63 | | Test a single Flow or Apex action in isolation | Action Execution | |
| 64 | |
| 65 | --- |
| 66 | |
| 67 | ## Mode A: Ad-Hoc Preview Testing |
| 68 | |
| 69 | > Full reference: `references/preview-testing.md` |
| 70 | |
| 71 | ### Test Case Planning |
| 72 | |
| 73 | If no utterances file is provided, auto-derive test cases from the `.agent` file: |
| 74 | 1. **Subagent-based utterances** -- one per non-start subagent from description keywords |
| 75 | 2. **Action-based utterances** -- target each key action |
| 76 | 3. **Guardrail test** -- off-topic utterance |
| 77 | 4. **Multi-turn scenarios** -- subagent transitions |
| 78 | 5. **Safety probes** -- adversarial utterances (always included) |
| 79 | |
| 80 | **Always present the plan first** -- never silently auto-run tests without showing what will be tested. Ask the user to review/modify before executing. |
| 81 | |
| 82 | ### Preview Execution |
| 83 | |
| 84 | Use `--authoring-bundle` to compile from the local `.agent` file (enables local trace files): |
| 85 | |
| 86 | ```bash |
| 87 | SESSION_ID=$(sf agent preview start --json \ |
| 88 | --authoring-bundle MyAgent \ |
| 89 | --target-org <org> 2>/dev/null \ |
| 90 | | jq -r '.result.sessionId') |
| 91 | |
| 92 | RESPONSE=$(sf agent preview send --json \ |
| 93 | --session-id |