关于 acceptance-criteria
acceptance-criteria 是面向产品负责人和 Scrum Master 的技能,用于为 ServiceNow Agile Development 2.0 故事编写可测试的验收标准。它以 Gherkin 场景覆盖常见流程,并可更新故事记录。
主要功能
- 01采用 Given/When/Then 格式
- 02覆盖正常、替代及错误场景
- 03检查边界、性能与安全条件
- 04按可测试性清单审查标准
- 05将标准写回故事记录
适用场景
- 01为待细化的用户故事编写验收标准
- 02补充错误及边界场景以支持 QA
- 03批量查找缺少验收标准的故事
- 04将生成的标准保存到 ServiceNow 故事
MCP 相关
通过 SN-Get-Record、SN-Query-Table 等 MCP 工具读取故事和 Epic,并使用 SN-Update-Record 将验收标准写回 ServiceNow。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ happy-technologies-llc/ happy-platform-skills --skill acceptance-criteria安装后在 Claude Code 中输入/acceptance-criteria确认已加载。
详细介绍
验收标准生成
概述
此技能为在 ServiceNow 的 Agile Development 2.0 模块中为用户故事和功能生成全面的验收标准提供了结构化方法。内容包括:
- 使用 Given/When/Then(Gherkin)格式编写验收标准
- 覆盖正常流程、替代流程和边缘情况
- 处理功能需求、验证规则和错误处理
- 定义性能阈值和安全约束
- 将标准关联到可测试条件,以满足 QA 就绪要求
- 使用格式良好的验收标准更新故事记录
适用场景: 产品负责人或 Scrum Master 需要在 ServiceNow SPM 中的冲刺规划或故事细化会议之前,定义清晰、可测试的验收标准时。
前提条件
- 插件:
com.snc.sdlc.agile.2.0(Agile Development 2.0) - 角色:
scrum_user、scrum_master或scrum_admin - 访问权限: 对
rm_story、rm_epic表具有读写权限 - 知识: 了解故事的功能需求和用户角色
流程
步骤 1:检索用户故事
在编写验收标准之前,获取故事记录以了解需求。
使用 MCP(Claude Code/Desktop):
Tool: SN-Get-Record
Parameters:
table_name: rm_story
sys_id: [story_sys_id]
fields: sys_id,number,short_description,description,acceptance_criteria,story_points,epic,sprint,state,priority,classification,product,assigned_to
如果只有故事编号,请先搜索:
使用 MCP:
Tool: SN-Query-Table
Parameters:
table_name: rm_story
query: number=STY0010001
fields: sys_id,number,short_description,description,acceptance_criteria,story_points,epic,sprint,state,priority,classification
limit: 1
使用 REST API:
GET /api/now/table/rm_story?sysparm_query=number=STY0010001&sysparm_fields=sys_id,number,short_description,description,acceptance_criteria,story_points,epic,sprint,state,priority,classification&sysparm_limit=1&sysparm_display_value=true
步骤 2:收集父级 Epic 的上下文
了解更广泛的功能背景有助于编写更全面的验收标准。
使用 MCP:
Tool: SN-Query-Table
Parameters:
table_name: rm_epic
query: sys_id=[epic_sys_id]
fields: sys_id,number,short_description,description,state,priority,acceptance_criteria
limit: 1
使用 REST API:
GET /api/now/table/rm_epic/[epic_sys_id]?sysparm_fields=sys_id,number,short_description,description,state,priority,acceptance_criteria&sysparm_display_value=true
步骤 3:查看相关故事以确保一致性
查询同一 Epic 下的同级故事,确保标准一致并避免重复。
使用 MCP:
Tool: SN-Query-Table
Parameters:
table_name: rm_story
query: epic=[epic_sys_id]^sys_id!=[story_sys_id]^ORDERBYpriority
fields: number,short_description,acceptance_criteria,state,story_points
limit: 20
使用 REST API:
GET /api/now/table/rm_story?sysparm_query=epic=[epic_sys_id]^sys_id!=[story_sys_id]^ORDERBYpriority&sysparm_fields=number,short_description,acceptance_criteria,state,story_points&sysparm_limit=20&sysparm_display_value=true
步骤 4:生成验收标准
按以下类别组织验收标准:
类别 1:正常流程(必需) 故事所描述的主要成功场景。
Scenario: Successful [action]
Given [precondition describing the initial state]
And [additional precondition if needed]
When [action the user performs]
And [additional action if needed]
Then [expected observable outcome]
And [additional outcome or side effect]
类别 2:替代流程(必需) 功能中有效但非默认的流程。
Scenario: [Action] with [variation]
Given [precondition with variation]
When [action with different input or context]
Then [expected outcome for this variation]
类别 3:错误处理(必需) 系统对无效输入或故障情况的响应方式。
Scenario: [Action] with invalid [input/state]
Given [precondition]
When [action with invalid data]
Then [error message or validation feedback]
And [system state remains unchanged]
类别 4:边缘情况(建议) 边界条件、空状态和极端情况。
Scenario: [Action] at boundary condition
Given [boundary precondition]
When [action at limit]
Then [expected behavior at boundary]
类别 5:性能和安全性(视情况而定) 必须可测试的非功能性需求。
Scenario: [Action] performance requirement
Given [load or data volume condition]
When [action is performed]
Then [response time or throughput requirement is met]
步骤 5:验证标准质量
根据质量检查清单逐项审查标准:
| 质量检查项 | 描述 | 通过标准 |
|---|---|---|
| 可测试 | 可通过明确的通过/失败结果进行验证 | 不含“快速”或“用户友好”等模糊表述 |
| 独立 | 每个场景都可独立成立 | 场景之间没有依赖关系 |
| 具体 | 包含明确的值 | 使用准确的数字、消息和状态 |
| 完整 | 涵盖需求的所有方面 | 正常流程 + 错误 + 边缘情况 |
| 简洁 | 不包含冗余场景 | 每个场景都测试独特条件 |
| 一致 | 符合故事范围 | 不超出或遗漏故事范围 |
步骤 6:更新故事记录
将最终确定的验收标准写回故事记录。
使用 MCP:
Tool: SN-Update-Record
Parameters:
table_name: rm_story
sys_id: [story_sys_id]
fields:
acceptance_criteria: |
Scenario: Successful customer search by phone number
Given I am logged in as a customer service representative
And I am on the customer search screen
When I enter a complete phone number "555-0123" in the search field
And I click the Search button
Then matching customer records are displayed within 2 seconds
And results show customer name, account number, and account status
And results are sorted by relevance with exact matches first
Scenario: Partial phone number search
Given I am logged in as a customer service representative
When I enter a partial phone number "555" in the search field
And I click the Search button
Then all customers with phone numbers containing "555" are displayed
And a maximum of 50 results are shown with pagination
Scenario: No matching results
Given I am logged in as a customer service representative
When I enter a phone number with no matching records
And I click the Search button
Then a message "No customers found matching the provided phone number" is displayed
And the search field retains the entered value
Scenario: Invalid phone number format
Given I am logged in as a customer service representative
When I enter non-numeric characters "abc-defg" in the phone search field
And I click the Search button
Then a validation message "Please enter a valid phone number" is displayed
And no search query is executed
Scenario: Empty search field submission
Given I am logged in as a customer service representative
When I click the Search button without entering a phone number
Then a validation message "Phone number is required" is displayed
Scenario: Search performance under load
Given the customer database contains over 1 million records
When I search for a phone number
Then results are returned within 3 seconds
使用 REST API:
PATCH /api/now/table/rm_story/[story_sys_id]
Content-Type: application/json
{
"acceptance_criteria": "Scenario: Successful customer search by phone number\n Given I am logged in as a customer service representative\n And I am on the customer search screen\n When I enter a complete phone number \"555-0123\" in the search field\n And I click the Search button\n Then matching customer records are displayed within 2 seconds\n And results show customer name, account number, and account status\n\nScenario: No matching results\n Given I am logged in as a customer service representative\n When I enter a phone number with no matching records\n Then a message \"No customers found\" is displayed"
}
步骤 7:批量更新缺少验收标准的故事
查找待办列表中缺少验收标准且需要细化的故事。
使用 MCP:
Tool: SN-Query-Table
Parameters:
table_name: rm_story
query: epic=[epic_sys_id]^acceptance_criteriaISEMPTY^state=-6
fields: sys_id,number,short_description,description,story_points,priority
limit: 25
使用 REST API:
GET /api/now/table/rm_story?sysparm_query=epic=[epic_sys_id]^acceptance_criteriaISEMPTY^state=-6&sysparm_fields=sys_id,number,short_description,description,story_points,priority&sysparm_limit=25&sysparm_display_value=true
工具用法
MCP 工具参考
| 工具 | 适用场景 |
|---|---|
SN-Get-Record | 按 sys_id 检索单个故事或 Epic |
SN-Query-Table | 查询故事、Epic 和相关记录 |
SN-Update-Record | 将验收标准写回故事 |
SN-Natural-Language-Search | 使用自然语言搜索需要验收标准的故事 |
REST API 参考
| 端点 | 方法 | 用途 |
|---|---|---|
/api/now/table/rm_story | GET | 查询用户故事并获取验收标准 |
/api/now/table/rm_story/{sys_id} | GET | 读取特定的用户故事记录 |
/api/now/table/rm_story/{sys_id} | PATCH | 更新用户故事的验收标准 |
/api/now/table/rm_epic | GET | 获取编写验收标准所需的史诗上下文 |
/api/now/table/rm_epic/{sys_id} | GET | 读取特定的史诗详情 |
最佳实践
- 从成功路径开始: 始终先定义主要的成功场景,然后再添加错误和边界情况
- 使用具体值: 将模糊的说法替换为具体的数字、消息和状态(例如,“在 2 秒内”,而不是“很快”)
- 每个场景只描述一种行为: 每个 Given/When/Then 代码块都应只测试一种行为或条件
- 避免实现细节: 验收标准描述系统的行为,而不是系统内部的构建方式
- 包含负向测试: 始终定义输入无效、未经授权访问和系统错误时的处理方式
- 覆盖边界条件: 测试空输入、最大长度、零数量和日期边界等限制
- 匹配用户故事的范围: 验收标准不应超出用户故事的边界;如果超出,可能需要拆分用户故事
- 与团队共同评审: 产品负责人、开发人员和测试人员应就验收标准达成一致
故障排除
“验收标准过于模糊,无法测试”
原因: 使用了“用户友好”“快速”或“直观”等主观措辞
解决方案: 替换为可衡量的表述:“在 2 秒内加载”“显示验证消息”“每页显示 10 条结果”
“用户故事有验收标准,但 QA 仍然不断失败”
原因: 验收标准可能遗漏了边界情况或错误处理场景
解决方案: 根据五个类别(成功路径、替代路径、错误、边界情况、性能)检查验收标准,并补充遗漏的场景
“无法更新 acceptance_criteria 字段”
原因: 字段级 ACL 限制,或用户故事处于锁定状态(例如 Closed)
解决方案: 确认你的角色具有对 rm_story.acceptance_criteria 的写入权限。处于 Closed 状态(state=7)的用户故事必须重新打开后才能编辑。
“保存后验收标准被截断”
原因: acceptance_criteria 字段可能有字符数限制
解决方案: 在字典(sys_dictionary)中检查字段长度。默认值为 4000 个字符。对于更长的验收标准,请使用描述字段或附加文档。
示例
示例 1:登录功能的验收标准
用户故事:“作为一名注册用户,我希望使用电子邮件和密码登录,以便访问我的控制面板”
生成的验收标准:
Scenario: Successful login with valid credentials
Given I am on the login page
And I have a registered account with email "[email protected]"
When I enter my email "[email protected]" and correct password
And I click the "Sign In" button
Then I am redirected to my dashboard
And my display name appears in the top navigation
And my last login timestamp is updated
Scenario: Login with incorrect password
Given I am on the login page
When I enter my email "[email protected]" and an incorrect password
And I click the "Sign In" button
Then an error message "Invalid email or password" is displayed
And no indication is given whether the email or password was wrong
And the failed attempt is logged for security auditing
Scenario: Login with unregistered email
Given I am on the login page
When I enter an unregistered email "[email protected]"
And I click the "Sign In" button
Then an error message "Invalid email or password" is displayed
Scenario: Account locked after failed attempts
Given I have failed login 5 times consecutively
When I attempt to log in a 6th time
Then my account is temporarily locked for 30 minutes
And a message "Account locked. Try again in 30 minutes." is displayed
And a security notification email is sent to my registered address
Scenario: Login with empty fields
Given I am on the login page
When I click "Sign In" without entering email or password
Then validation messages appear for both required fields
And no authentication request is sent
Scenario: Session timeout after inactivity
Given I am logged in
When I am inactive for 30 minutes
Then my session expires
And I am redirected to the login page with message "Session expired"
示例 2:为冲刺待办事项批量生成验收标准
场景: 为即将开始的冲刺中尚无验收标准的所有用户故事生成验收标准。
步骤 1 - 查找没有验收标准的用户故事:
Tool: SN-Query-Table
Parameters:
table_name: rm_story
query: sprint=[sprint_sys_id]^acceptance_criteriaISEMPTY
fields: sys_id,number,short_description,description,story_points
limit: 30
步骤 2 - 为每个用户故事生成并更新:
Tool: SN-Update-Record
Parameters:
table_name: rm_story
sys_id: [story_sys_id]
fields:
acceptance_criteria: |
Scenario: [Primary success scenario]
Given [precondition]
When [user action]
Then [expected result]
Scenario: [Error handling scenario]
Given [precondition]
When [invalid action]
Then [error feedback]
输出摘要:
ACCEPTANCE CRITERIA GENERATION REPORT
Sprint: Sprint 2026-04-A
Stories Updated: 8 of 8
STY0010101 - Add to cart (3 scenarios: happy path, out of stock, max quantity)
STY0010102 - Remove from cart (3 scenarios: single item, last item, undo)
STY0010103 - Update quantity (4 scenarios: increase, decrease, zero, max)
STY0010104 - Apply coupon code (4 scenarios: valid, expired, invalid, stacking)
STY0010105 - View cart total (3 scenarios: with tax, empty cart, multi-currency)
STY0010106 - Save cart for later (3 scenarios: save, restore, expiration)
STY0010107 - Share cart via link (3 scenarios: generate link, access, expired link)
STY0010108 - Cart item availability check (3 scenarios: in stock, limited, unavailable)
Total Scenarios: 26
Stories Ready for Sprint Planning: 8/8
相关技能
spm/agile-story-generation- 根据需求生成用户故事spm/project-insights- 跟踪项目健康状况和速度指标spm/planning-summarization- 总结冲刺和发布计划development/automated-testing- 根据验收标准生成自动化测试用例development/business-rules- 实现验收标准中引用的验证规则