bdd-patterns by thebushidocollective/han
npx skills add https://github.com/thebushidocollective/han --skill bdd-patterns掌握行为驱动开发模式,编写清晰、业务可读的规范,以驱动实现。
基本的 BDD 模式包含三个部分:
Feature: User Authentication
Scenario: Successful login with valid credentials
Given a registered user with email "user@example.com"
And the user has password "secure123"
When the user submits the login form with correct credentials
Then the user should be redirected to the dashboard
And a session should be created
Feature: Shopping Cart
As a customer
I want to manage items in my cart
So that I can purchase products I'm interested in
Background:
Given I am logged in as a customer
And the product catalog is available
Scenario: Add item to empty cart
Given my cart is empty
When I add "Blue T-Shirt" to my cart
Then my cart should contain 1 item
And the cart total should be $29.99
Scenario: Remove item from cart
Given my cart contains "Blue T-Shirt"
When I remove "Blue T-Shirt" from my cart
Then my cart should be empty
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
Scenario Outline: Password validation
Given I am on the registration page
When I enter password "<password>"
Then I should see "<message>"
Examples:
| password | message |
| abc | Password too short |
| abcdefgh | Password needs a number |
| abcdefgh1 | Password accepted |
| abcdefgh1! | Password accepted |
# Ruby/Cucumber example
Given('a registered user with email {string}') do |email|
@user = User.create!(email: email, password: 'password123')
end
When('the user submits the login form with correct credentials') do
visit login_path
fill_in 'Email', with: @user.email
fill_in 'Password', with: 'password123'
click_button 'Log In'
end
Then('the user should be redirected to the dashboard') do
expect(page).to have_current_path(dashboard_path)
end
在以下情况下使用 bdd-patterns:
每周安装量
85
代码仓库
GitHub 星标数
128
首次出现
2026年1月22日
安全审计
安装于
opencode77
codex75
gemini-cli73
github-copilot68
kimi-cli62
amp62
Master Behavior-Driven Development patterns to write clear, business-readable specifications that drive implementation.
The fundamental BDD pattern uses three parts:
Given : The initial context or preconditions
When : The action or event being tested
Then : The expected outcome or result
Feature: User Authentication
Scenario: Successful login with valid credentials Given a registered user with email "user@example.com" And the user has password "secure123" When the user submits the login form with correct credentials Then the user should be redirected to the dashboard And a session should be created
Feature: Shopping Cart
As a customer
I want to manage items in my cart
So that I can purchase products I'm interested in
Background:
Given I am logged in as a customer
And the product catalog is available
Scenario: Add item to empty cart
Given my cart is empty
When I add "Blue T-Shirt" to my cart
Then my cart should contain 1 item
And the cart total should be $29.99
Scenario: Remove item from cart
Given my cart contains "Blue T-Shirt"
When I remove "Blue T-Shirt" from my cart
Then my cart should be empty
Scenario Outline: Password validation
Given I am on the registration page
When I enter password "<password>"
Then I should see "<message>"
Examples:
| password | message |
| abc | Password too short |
| abcdefgh | Password needs a number |
| abcdefgh1 | Password accepted |
| abcdefgh1! | Password accepted |
# Ruby/Cucumber example
Given('a registered user with email {string}') do |email|
@user = User.create!(email: email, password: 'password123')
end
When('the user submits the login form with correct credentials') do
visit login_path
fill_in 'Email', with: @user.email
fill_in 'Password', with: 'password123'
click_button 'Log In'
end
Then('the user should be redirected to the dashboard') do
expect(page).to have_current_path(dashboard_path)
end
Use bdd-patterns when you need to:
Weekly Installs
85
Repository
GitHub Stars
128
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
opencode77
codex75
gemini-cli73
github-copilot68
kimi-cli62
amp62
后端测试指南:API端点、业务逻辑与数据库测试最佳实践
11,800 周安装