Mom's Guide to Behave (Python Behaviour Driven Development)
Updated: May 22, 2025

Behave is Python’s BDD framework that turns user stories into testable scenarios. Let’s break it down—Mom style!
What is Behave?
Consider Behave as a cookbook for testing your software. Similar to following a recipe to bake cookies, Behave allows you to write tests in simple language that outline how your software is expected to function. Behave is written in plain English,coded in python.Behave is like mom saying: ‘Sure, you can go out...’ But Python is quietly running checks on your location, money, and grades."
The Key Ingredients
Feature files: They are like Mom's recipe cards
Neatly written in plain English(Gherkins Language).
Easy to follow.
Ghekin's Cheat Sheet
Gherkin's Keyword | What Does it do? | Mom's Example |
|---|---|---|
Feature | Describes what you are testing ? | Feature: Grocery Budget Management |
Background | Common setup for all scenarios | Given I have $1000; And rent is paid |
Scenario | A specific case or test example | Scenario: Buying veggies under budget |
Given | Pre-condition or starting state | Given I have $200 |
When | The action you're testing | When I spend $150 on groceries. |
Then | The expected result | Then I should be left with $50(hopefully!) |
And/But | Add more steps to any part | And I buy milk; But I return the chips |
@Tags | Labels or groups scenarios | @groceries, @rent, @utilities |
Scenario Outline | Template to run the same test with different data |
Guidelines for Writing Feature Files
Ensure all your feature files have a .feature extension - Just like every recipe needs a label!"
Begin with a Feature Title "Mark your jar before adding money!"
Craft Scenarios as Short Stories "Each dollar spent should tell a tale!"
Adopt Declarative Steps (Avoid Imperative) "Mom says what should happen, not how to do it!"
Utilize Background for Common Setup "Use Background like a family rule—establish it once, and let all scenarios adhere to it (unless an exception is needed)!"
Tag Scenarios for Organization."Label your money envelopes—savings, spending, emergencies!"

Step Definitions - These are the actual Python code that makes the steps work.Like the actual cooking instructions behind the recipe.
Guidelines for Writing Step definitions
1. Match the Gherkin Steps Exactly ."If the recipe says ‘1 cup sugar,’ don’t use salt!"
2.Use context to Share Data to use across steps."Like passing the grocery list between family members!"
3. Keep Steps Atomic (One Action per Step)."One chore at a time—no multitasking!"
4.Use Parameters {}for Flexibility."A good budget works with any number!"
5.Address Assertions Transparently."Verify the receipt before exiting the store!"
Why Use Behave?
Clear instructions (no vague "pinch of salt" here!).
Collaboration (even non-techies can read Gherkin!).
Predictable results (no burnt cookies!).
Moms love comparing to get the best!
Tool | Mom's Verdict |
|---|---|
Behave | "Easy-to-read recipes!" (Gherkin) |
pytest | "Too technical—no stories!" |
unittest | "Where’s the flavor?!" |
Hungry for more? Check out:
Behave Documentation
Selenium for Python Documentation
GitHub Repo with a project with Python Behave BDD


