🧪Behavior-Driven Development (BDD)
Also known as BDD, Behaviour-Driven Development, Gherkin, Cucumber (Testing)
Writing features as Given, When, Then lines. The lines also run as tests.
Think of it like
Think of it like writing the rules of a game in plain words first. Then everyone plays it the same way.
Example
Emma runs a shop, and Jack writes the code. They write the checkout rules together as Given, When, Then lines. Jack is done when every line passes.
Why it matters
The people who want the feature and the people who build it agree first. Then nobody codes the wrong thing.
Definition
Example code
gherkin
Scenario: Pay with a valid card
Given a cart with one mug
When I pay with a valid card
Then I see "Thank you"Common mistake
Key takeaways
- 1Plain words. Anyone on the team can read it.
- 2Given, When, Then. Scene, action, result.
- 3Runs as a test. The sentences are checked.