npx skills add https://github.com/danhvb/my-ba-skills --skill 'Acceptance Criteria'定义清晰、可测试的验收标准,明确说明需求或用户故事何时被视为已完成且运行正确。
结构:
Given [前提条件/上下文]
When [动作/事件]
Then [预期结果]
And [附加结果]
示例 - 登录:
Scenario: 使用有效凭证成功登录
Given 我在登录页面
And 我是一个注册用户,邮箱为 "user@example.com"
When 我输入 "user@example.com" 作为邮箱
And 我输入 "ValidPassword123" 作为密码
And 我点击 "Sign In" 按钮
Then 我应该被重定向到仪表板
And 我应该看到欢迎信息 "Welcome, John"
And 我的上次登录时间应该被更新
Scenario: 使用无效密码登录失败
Given 我在登录页面
And 我是一个注册用户
When 我输入有效的邮箱
And 我输入错误的密码
And 我点击 "Sign In" 按钮
Then 我应该看到错误信息 "Invalid email or password"
And 我应该停留在登录页面
And 账户锁定计数器应该增加
Scenario: 5次失败尝试后账户被锁定
Given 我在登录页面
And 我已经登录失败 4 次
When 我第 5 次登录失败
Then 我的账户应该被锁定 30 分钟
And 我应该看到信息 "Account locked. Try again in 30 minutes"
And 我应该收到一封安全警报邮件
示例 - 结账:
## 用户故事:访客结账
### 验收标准
- [ ] 访客无需创建账户即可进行结账
- [ ] 邮箱字段是必填项且经过验证
- [ ] 收货地址表单包含:姓名、地址、城市、州、邮编、国家、电话
- [ ] 提交时,所有必填字段如果为空则显示验证错误
- [ ] 调用地址验证 API 并建议更正
- [ ] 显示配送选项及实时价格
- [ ] 订单摘要显示所有商品、数量和价格
- [ ] 支付表单接受信用卡信息
- [ ] 支付成功后创建订单
- [ ] 确认页面显示订单号和详情
- [ ] 在 1 分钟内发送确认邮件
- [ ] 订单完成后向访客提供创建账户的选项
示例 - 购物车:
## 用户故事:添加到购物车
### 理想路径
- 用户选择产品变体(尺寸、颜色)
- 用户点击"添加到购物车"
- 产品以正确的数量添加到购物车
- 购物车图标更新商品数量
- 迷你购物车显示添加产品确认
- 用户可以继续购物或前往购物车
### 边界情况
- 缺货:"添加到购物车"按钮禁用,显示"缺货"
- 库存有限:显示"仅剩 3 件"警告
- 最大数量:显示"每位顾客限购 5 件"信息
- 已在购物车中:更新数量而非添加重复项
- 未选择变体:提示先选择变体
### 错误场景
- 网络错误:显示"无法添加。请重试"
- 库存变更:显示"抱歉,此商品已不再可用"
- 会话过期:重定向到登录页面,返回时保留购物车
Scenario: 信用卡支付成功
Given 我的购物车中有商品,总计 $99.99
And 我在支付页面
When 我输入有效的卡号 "4242 4242 4242 4242"
And 我输入有效期 "12/27" 和 CVV "123"
And 我点击 "Pay Now"
Then 支付应处理成功
And 我应该看到订单确认页面
And 我应该收到确认邮件
And 订单状态应为 "Processing"
Scenario: 支付被拒绝
Given 我在支付页面
When 我输入一张将被拒绝的卡
And 我点击 "Pay Now"
Then 我应该看到 "Payment declined. Please try another card"
And 我应该停留在支付页面
And 不应创建任何订单
And 不应产生任何扣款
Scenario: 需要 3D Secure 认证
Given 我使用需要 3DS 的卡进行支付
When 我提交支付
Then 我应该看到 3D Secure 弹窗
When 我完成验证
Then 支付应正常处理
Scenario: 将合格的潜在客户转化为商机
Given 我正在查看一个评分 >= 75 的潜在客户
And 潜在客户状态为 "Qualified"
When 我点击 "Convert to Opportunity"
Then 我应该看到转化对话框
And 我应该能够创建或选择账户
And 应创建新的联系人
And 应使用潜在客户数据创建新的商机
And 原始潜在客户应标记为 "Converted"
And 应记录转化历史
Scenario: 无法转化不合格的潜在客户
Given 我正在查看一个评分 < 60 的潜在客户
When 我点击 "Convert to Opportunity"
Then 我应该看到信息 "Lead must be qualified before conversion"
And 转化对话框不应打开
Scenario: 低于 $1000 的采购订单自动批准
Given 我创建了一个价值 $500 的采购订单
When 我提交采购订单
Then 采购订单状态应为 "Approved"
And 我应该看到信息 "Auto-approved under $1,000 threshold"
And 不应发送任何审批通知
Scenario: 采购订单路由给经理审批
Given 我创建了一个价值 $5,000 的采购订单
When 我提交采购订单
Then 采购订单状态应为 "Pending Approval"
And 我的经理应收到审批通知
And 我应该看到信息 "Sent to manager for approval"
Scenario: 经理批准采购订单
Given 我是一名经理
And 我有一个待审批的采购订单
When 我点击 "Approve"
And 我输入审批意见
Then 采购订单状态应变为 "Approved"
And 应通知申请者
And 采购订单应发送给供应商
Scenario: 离线查看缓存数据
Given 我之前查看过我的订单历史
And 我现在处于离线状态
When 我打开应用
And 我导航到订单历史
Then 我应该看到缓存的订单
And 我应该看到 "Offline - Last updated: [timestamp]"
And 我不应看到加载指示器
Scenario: 尝试需要网络连接的操作
Given 我处于离线状态
When 我尝试下新订单
Then 我应该看到 "You're offline. Connect to place order"
And 我应该有将购物车保存以备后用的选项
And 操作不应继续
Scenario: 重新联网时自动同步
Given 我在离线时进行了更改
When 我重新获得网络连接
Then 应用应自动同步更改
And 我应该看到简短的 "Syncing..." 指示器
And 同步完成后我应该看到 "Up to date"
✅ 应该做:
❌ 不应该做:
Given 字段 X 为空
When 用户提交表单
Then 字段 X 下方显示错误 "X is required"
And 字段 X 以红色高亮显示
And 表单未提交
Given 有 N 个项目符合条件
When 用户搜索 [条件]
Then 显示 N 个结果
And 结果按 [默认排序] 排序
And 每个结果显示 [字段]
创建:输入验证、成功信息、列表更新
读取:显示正确数据、处理空状态
更新:验证更改、显示成功、反映更改
删除:确认提示、成功信息、项目移除
编写验收标准后:
每周安装次数
–
代码仓库
首次出现
–
安全审计
Define clear, testable acceptance criteria that specify exactly when a requirement or user story is considered complete and working correctly.
Structure :
Given [precondition/context]
When [action/event]
Then [expected outcome]
And [additional outcome]
Example - Login :
Scenario: Successful login with valid credentials
Given I am on the login page
And I am a registered user with email "user@example.com"
When I enter "user@example.com" 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
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
Example - Checkout :
## 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
Example - Shopping Cart :
## 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
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
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
✅ Do :
❌ Don't :
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]
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
After writing acceptance criteria:
Weekly Installs
–
Repository
First Seen
–
Security Audits
测试策略完整指南:单元/集成/E2E测试金字塔与自动化实践
11,200 周安装