关于 Acceptance Criteria
帮助产品、需求和 QA 团队编写清晰且可测试的验收标准。涵盖 Given-When-Then、清单和场景格式,并提供完整性与可测试性检查建议。
主要功能
- 01Given-When-Then 验收标准
- 02清单与场景格式
- 03领域示例
- 04可测试性与完整性检查
- 05边界和错误情况指引
适用场景
- 01为迭代用户故事编写验收标准
- 02在 FRS 中定义需求
- 03准备 UAT 测试用例
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ danhvb/ my-ba-skills --skill acceptance-criteria安装后在 Claude Code 中输入/acceptance-criteria确认已加载。
详细介绍
验收标准技能
目的
定义清晰、可测试的验收标准,准确说明何时可认为某项需求或用户故事已完成且正常运行。
适用场景
- 为敏捷冲刺编写用户故事
- 在 FRS 中定义需求
- 规划 UAT 测试用例
- 为功能制定完成定义
验收标准格式
1. Given-When-Then(Gherkin)
结构:
Given [precondition/context]
When [action/event]
Then [expected outcome]
And [additional outcome]
示例 - 登录:
Scenario: Successful login with valid credentials
Given I am on the login page
And I am a registered user with email "[email protected]"
When I enter "[email protected]" as email
And I enter "ValidPassword123" as password
And I click the "Sign In" button
Then I should be redirected to the dashboard
And I should see a welcome message "Welcome, John"
And my last login time should be updated
Scenario: Failed login with invalid password
Given I am on the login page
And I am a registered user
When I enter valid email
And I enter incorrect password
And I click the "Sign In" button
Then I should see error message "Invalid email or password"
And I should remain on the login page
And account lockout counter should increment
Scenario: Account lockout after 5 failed attempts
Given I am on the login page
And I have failed login 4 times
When I fail login a 5th time
Then my account should be locked for 30 minutes
And I should see message "Account locked. Try again in 30 minutes"
And I should receive a security alert email
2. 清单格式
示例 - 结账:
## User Story: Guest Checkout
### Acceptance Criteria
- [ ] Guest can proceed to checkout without creating account
- [ ] Email field is required and validated
- [ ] Shipping address form includes: name, address, city, state, zip, country, phone
- [ ] All required fields show validation errors if empty on submit
- [ ] Address validation API is called and suggests corrections
- [ ] Shipping options are displayed with real-time prices
- [ ] Order summary shows all items, quantities, and prices
- [ ] Payment form accepts credit card information
- [ ] Order is created upon successful payment
- [ ] Confirmation page shows order number and details
- [ ] Confirmation email is sent within 1 minute
- [ ] Guest is offered option to create account after order
3. 基于场景的格式
示例 - 购物车:
## User Story: Add to Cart
### Happy Path
- User selects product variant (size, color)
- User clicks "Add to Cart"
- Product is added to cart with correct quantity
- Cart icon updates with item count
- Mini cart shows added product confirmation
- User can continue shopping or go to cart
### Edge Cases
- Out of stock: "Add to Cart" button disabled, shows "Out of Stock"
- Limited stock: Shows "Only 3 left" warning
- Maximum quantity: "Only 5 per customer" message
- Already in cart: Updates quantity instead of adding duplicate
- Variant not selected: Prompts to select variant first
### Error Scenarios
- Network error: Shows "Unable to add. Please try again"
- Inventory changed: Shows "Sorry, this item is no longer available"
- Session expired: Redirects to login, preserves cart on return
特定领域示例
电子商务:支付处理
Scenario: Successful credit card payment
Given I have items in my cart totaling $99.99
And I am on the payment page
When I enter valid card number "4242 4242 4242 4242"
And I enter expiration "12/27" and CVV "123"
And I click "Pay Now"
Then the payment should be processed successfully
And I should see order confirmation page
And I should receive confirmation email
And order status should be "Processing"
Scenario: Payment declined
Given I am on the payment page
When I enter a card that will be declined
And I click "Pay Now"
Then I should see "Payment declined. Please try another card"
And I should remain on payment page
And no order should be created
And no charge should be made
Scenario: 3D Secure authentication required
Given I am paying with a card requiring 3DS
When I submit payment
Then I should see 3D Secure popup
When I complete verification
Then payment should process normally
CRM:潜在客户转化
Scenario: Convert qualified lead to opportunity
Given I am viewing a lead with score >= 75
And lead status is "Qualified"
When I click "Convert to Opportunity"
Then I should see conversion dialog
And I should be able to create or select account
And new contact should be created
And new opportunity should be created with lead data
And original lead should be marked "Converted"
And conversion history should be logged
Scenario: Cannot convert unqualified lead
Given I am viewing a lead with score < 60
When I click "Convert to Opportunity"
Then I should see message "Lead must be qualified before conversion"
And conversion dialog should not open
ERP:采购订单审批
Scenario: PO auto-approved under $1000
Given I create a purchase order for $500
When I submit the PO
Then PO status should be "Approved"
And I should see message "Auto-approved under $1,000 threshold"
And no approval notification should be sent
Scenario: PO routes to manager for approval
Given I create a purchase order for $5,000
When I submit the PO
Then PO status should be "Pending Approval"
And my manager should receive approval notification
And I should see message "Sent to manager for approval"
Scenario: Manager approves PO
Given I am a manager
And I have a pending PO for approval
When I click "Approve"
And I enter approval comments
Then PO status should change to "Approved"
And requestor should be notified
And PO should be sent to vendor
移动端/网页:离线功能
Scenario: View cached data offline
Given I have previously viewed my order history
And I am now offline
When I open the app
And I navigate to Order History
Then I should see cached orders
And I should see "Offline - Last updated: [timestamp]"
And I should not see loading spinner
Scenario: Attempt action that requires connectivity
Given I am offline
When I try to place a new order
Then I should see "You're offline. Connect to place order"
And I should have option to save cart for later
And action should not proceed
Scenario: Auto-sync when back online
Given I made changes while offline
When I regain internet connection
Then app should automatically sync changes
And I should see brief "Syncing..." indicator
And I should see "Up to date" when complete
最佳实践
编写优质验收标准
✅ 应该:
- 具体且可衡量
- 覆盖正常流程和边缘情况
- 包含错误场景
- 确保每条标准都可独立测试
- 使用一致的表述
- 从用户视角考虑
- 包含数据验证规则
- 指定时间要求(如适用)
❌ 不应该:
- 含糊不清(“系统应该很快”)
- 忽略错误处理
- 假设读者掌握隐含知识
- 标准过于细化(达到测试用例级别)
- 忘记边缘情况
- 在一条标准中混入多个功能
可测试性检查清单
- QA 能否据此编写测试用例?
- 预期结果是否明确?
- 能否客观判定通过或失败?
- 是否指定了具体值(而不是“有效输入”)?
- 是否指定了时间要求?
完整性检查清单
- 是否覆盖正常流程?
- 是否覆盖错误情况?
- 是否覆盖边缘情况?
- 是否覆盖空值/null 状态?
- 是否覆盖权限/访问场景?
- 是否覆盖移动端/响应式场景?
常见模式
表单验证
Given field X is empty
When user submits form
Then error "X is required" is shown below field X
And field X is highlighted in red
And form is not submitted
列表/搜索
Given there are N items matching criteria
When user searches for [criteria]
Then N results are displayed
And results are sorted by [default sort]
And each result shows [fields]
CRUD 操作
Create: Input validation, success message, list updates
Read: Display correct data, handle empty state
Update: Validate changes, show success, reflect changes
Delete: Confirm prompt, success message, item removed
工具
- Lark/Notion:将标准与用户故事一同记录
- Jira:故事中的验收标准字段
- Gherkin:用于自动化的正式 BDD 语法
- Cucumber/SpecFlow:使用 Gherkin 进行自动化测试
后续步骤
编写验收标准后:
- 与产品负责人评审
- 与 QA 评审可测试性
- 纳入就绪定义
- 用于创建 UAT 测试用例
参考资料
- 行为驱动开发(BDD)
- Gherkin 语法参考
- 用户故事地图(Jeff Patton)
评论
支持 Markdown