行为驱动开发 (BDD) 是一种方法,用简洁、结构化的语言 (Given-When-Then) 描述软件行为,使技术人员和非技术人员都能理解——在开发人员、测试人员和业务利益相关者之间架起沟通桥梁,测试源自这些描述。
BDD 是什么
text
BDD focuses on describing BEHAVIOR in business-readable language:
→ write SCENARIOS in a structured natural-language format (Gherkin):
GIVEN some initial context
WHEN an action/event happens
THEN an expected outcome occurs
→ these scenarios are both DOCUMENTATION and executable TESTS
→ Bridges devs, QA, and BUSINESS stakeholders with a shared, readable language.
一个 Gherkin 场景
gherkin
Feature: User login
Scenario: Successful login
Given a registered user with valid credentials
When they submit the login form
Then they should see their dashboard
And a welcome message should be displayed
