dx-devops-test-failures-analyze

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Analyze DevOps Center Test Failures

分析DevOps Center测试失败

Parses a test failure or Code Analyzer violation payload, explains it in plain language, produces prioritized improvement suggestions, and — only on explicit user request — creates a tracked fix work item. Parts 1–2 are pure reasoning (no writes); Part 3 is an optional, confirmation-gated write.
Never expose raw JSON, stack traces, or internal Salesforce error codes to the user. Always translate to file name, method, line, and plain description.

解析测试失败或Code Analyzer违规负载,用通俗语言进行解释,生成按优先级排序的改进建议,并仅在用户明确请求时创建可跟踪的修复WorkItem。第1-2部分为纯推理操作(无写入);第3部分为可选操作,需经确认后方可执行写入。
切勿向用户暴露原始JSON、堆栈跟踪或Salesforce内部错误码。 始终转换为文件名、方法、行号和直白描述。

Prerequisites

前置条件

  • Parts 1–2 (analysis): If the failure payload is already in context, no prerequisites are needed — this is pure reasoning. If you must fetch the payload yourself, run prerequisites (
    references/prerequisite-checks.md
    , Prereqs 1–4) and obtain the execution result via
    dx-devops-test-suite-run
    (its polling step).
  • Part 3 (work item): Run Prerequisites 1–4. You also need a
    DevopsProjectId
    to file under and an
    OwnerId
    (assignee). See
    references/work-item-creation.md
    .

  • 第1-2部分(分析): 如果上下文已包含失败负载,则无需前置条件——此为纯推理操作。若需自行获取负载,请执行前置检查(
    references/prerequisite-checks.md
    ,前置条件1-4),并通过
    dx-devops-test-suite-run
    (其轮询步骤)获取执行结果。
  • 第3部分(工作项): 执行前置条件1-4。还需
    DevopsProjectId
    用于归档,以及
    OwnerId
    (经办人)。详情请见
    references/work-item-creation.md

Part 1 — Classify and explain each failure

第1部分 — 分类并解释每个失败

Determine the failure category, then for each failure extract and translate to plain language: offending file/class, method, line number, the rule or assertion violated, and a fix direction (without writing code). Group failures by category if more than one.
CategoryDescription
Assertion failureA test assertion failed (expected vs actual mismatch)
ExceptionAn unhandled exception was thrown
Code Analyzer violationA static-analysis rule was violated (e.g.
ApexCRUDViolation
)
TimeoutTest exceeded execution time limit
Compile errorClass failed to compile
Output format:
text
Test failure summary:

<N> failure(s) found:

1. [<Category>] `<ClassName>.cls` — `<methodName>()` at line <N>
   What happened: <plain-language description>
   Rule violated: <ruleName or assertion description>
   Fix direction: <plain-language suggestion>
Full category/pattern tables and Code Analyzer rule translations:
references/failure-categories.md
and
references/code-analyzer-violations.md
.
Empty / no-data case: If the payload contains no failures or violations, report that clearly (e.g. "No failures found in the provided execution results.") and stop. Do NOT fabricate failures or suggestions.

确定失败类别,然后针对每个失败提取信息并转换为通俗语言:问题文件/类、方法、行号、违反的规则或断言,以及修复方向(无需编写代码)。若存在多个失败,按类别分组。
类别描述
断言失败测试断言失败(预期值与实际值不匹配)
异常抛出未处理的异常
Code Analyzer违规违反静态分析规则(例如
ApexCRUDViolation
超时测试超出执行时间限制
编译错误类编译失败
输出格式:
text
测试失败摘要:

发现<N>个失败:

1. [<类别>] `<ClassName>.cls` — `<methodName>()` 位于第<N>行
   问题描述:<通俗语言说明>
   违反规则:<规则名称或断言描述>
   修复方向:<通俗语言建议>
完整的类别/模式表及Code Analyzer规则翻译请见:
references/failure-categories.md
references/code-analyzer-violations.md
空数据/无结果情况: 如果负载中无失败或违规,请明确告知(例如:“在提供的执行结果中未发现失败。”)并停止操作。切勿虚构失败或建议。

Part 2 — Improvement suggestions

第2部分 — 改进建议

Run this after execution completes with failures, not on static source. For each failed test, reason over the failure message (the primary signal) to identify what the test is not handling, then produce a specific, actionable suggestion and a fix location (Test vs Production code). The full failure-pattern → suggestion mapping is in
references/failure-categories.md
.
text
Test improvement suggestions based on execution results:

`<testMethodName>()` — [Assertion Failure / Exception / etc.]
Failure: "<failure message>"
What this reveals: <plain-language explanation>
Suggestion: <specific, actionable recommendation>
Fix location: Test | Production code

Overall: <N> improvement(s) across <M> failed test(s).
Do not rewrite the test — only describe what needs to change and why. Fix location: Production code indicates a code defect exposed by a sound test (track separately, not a test-quality blocker). Fix location: Test indicates the test needs hardening (setup, assertions, edge cases).

仅在执行完成且存在失败时运行此部分,而非针对静态源代码。针对每个失败测试,根据失败消息(核心信号)推理测试未处理的场景,然后生成具体、可执行的建议以及修复位置(测试代码 vs 生产代码)。完整的失败模式→建议映射请见
references/failure-categories.md
text
基于执行结果的测试改进建议:

`<testMethodName>()` — [断言失败 / 异常 / 等]
失败信息:"<失败消息>"
问题揭示:<通俗语言解释>
建议:<具体、可执行的建议>
修复位置:测试代码 | 生产代码

总体:<M>个失败测试中共有<N>项改进建议。
请勿重写测试——仅描述需要更改的内容及原因。修复位置:生产代码表示测试暴露了代码缺陷(需单独跟踪,不属于测试质量阻塞项)。修复位置:测试代码表示测试需要强化(设置、断言、边缘场景)。

Part 3 — Create a fix work item (optional, on request only)

第3部分 — 创建修复工作项(可选,仅在请求时触发)

Trigger only when the user wants to create a fix work item, log a remediation, or assign a failure to a developer. This is a write operation with a mandatory confirmation gate. Follow
references/work-item-creation.md
for inputs, the subject/assignee/project confirmation gate, the
sf data create record --sobject WorkItem
call, and error handling.
Use
WorkItem
(no namespace) —
DevopsWorkItem
is not a supported sObject in this org version.
If no
DevopsProject
exists in the org, report that the work item cannot be created until a project is set up — do NOT fabricate a project or proceed.

仅在用户想要创建修复工作项、记录补救措施或将失败任务分配给开发人员时触发。这是一项写入操作,必须经过确认环节。请遵循
references/work-item-creation.md
中的输入要求、主题/经办人/项目确认环节、
sf data create record --sobject WorkItem
调用方法以及错误处理流程。
使用
WorkItem
(无命名空间)——此组织版本不支持
DevopsWorkItem
对象。
如果组织中不存在
DevopsProject
,请告知用户需先设置项目才能创建工作项——切勿虚构项目或继续操作。

Related skills

相关技能

  • dx-devops-test-suite-run
    — produces the failure payload (via its polling step) that feeds this skill.
  • dx-devops-test-suite-assignments-configure
    — assign/strengthen the suites whose tests are failing.
  • platform-apex-generate
    /
    platform-apex-test-generate
    — to actually write fix code or new test classes (out of scope here).
  • dx-devops-test-suite-run
    — 生成供本技能使用的失败负载(通过其轮询步骤)。
  • dx-devops-test-suite-assignments-configure
    — 分配/强化测试失败的测试套件。
  • platform-apex-generate
    /
    platform-apex-test-generate
    — 用于实际编写修复代码或新测试类(不在本技能范围内)。",