Behaviour-Driven Development is not a testing technique โ it is a collaboration practice. BDD brings business stakeholders, developers, and testers together to define application behaviour in a shared language before any code is written. The output is a set of executable specifications โ plain-English scenarios that describe what the system should do, which are then automated as tests. When done correctly, BDD produces living documentation that is always up to date because the documentation is the test suite.
The BDD Philosophy โ Collaboration Before Automation
BDD is often misunderstood as “writing tests in Gherkin.” The real value is the conversation that produces the Gherkin โ the Three Amigos session where business, dev, and QA align on what to build.
# The BDD workflow โ Three Amigos to Living Documentation
BDD_WORKFLOW = [
{
"phase": "1. Discovery (Three Amigos Session)",
"who": "Product Owner + Developer + Tester",
"activity": "Discuss the user story; ask 'What should happen when...?' questions",
"output": "Shared understanding of expected behaviour; concrete examples",
"time": "30 minutes per user story",
},
{
"phase": "2. Formulation (Write Scenarios)",
"who": "Tester (with PO review)",
"activity": "Convert examples into Gherkin scenarios (Given/When/Then)",
"output": ".feature files โ executable specifications in plain English",
"time": "15 minutes per scenario",
},
{
"phase": "3. Automation (Step Definitions)",
"who": "SDET / Automation Engineer",
"activity": "Bind Gherkin steps to automation code (Selenium, API calls)",
"output": "Automated tests that run the scenarios against the application",
"time": "30-60 minutes per scenario",
},
{
"phase": "4. Living Documentation",
"who": "Entire team",
"activity": "Feature files serve as always-up-to-date documentation",
"output": "Stakeholders read .feature files to understand system behaviour",
"time": "Ongoing โ updated as requirements change",
},
]
# BDD vs traditional test automation
COMPARISON = {
"Traditional Automation": {
"specification": "Test cases in a test management tool (TestRail, Jira)",
"documentation": "Separate from code; drifts out of date",
"collaboration": "Tester writes tests after development; silos between roles",
"language": "Technical โ code that only testers understand",
"example": "def test_login_valid(): driver.find_element(By.ID, 'user')...",
},
"BDD Automation": {
"specification": "Feature files in version control alongside code",
"documentation": "IS the test โ always up to date because it runs",
"collaboration": "Three Amigos discuss behaviour before development starts",
"language": "Business language โ anyone can read and review",
"example": "Given I am on the login page\nWhen I enter valid credentials\nThen I should see the dashboard",
},
}
# BDD tools by language
BDD_TOOLS = [
{"language": "Python", "tool": "Behave or pytest-bdd", "runner": "behave / pytest"},
{"language": "JavaScript", "tool": "Cucumber.js", "runner": "cucumber-js"},
{"language": "Java", "tool": "Cucumber-JVM", "runner": "JUnit / TestNG"},
{"language": "C# (.NET)", "tool": "SpecFlow / Reqnroll", "runner": "NUnit / xUnit"},
{"language": "Ruby", "tool": "Cucumber (original)", "runner": "cucumber"},
]
print("BDD Workflow:")
for phase in BDD_WORKFLOW:
print(f"\n {phase['phase']}")
print(f" Who: {phase['who']}")
print(f" Activity: {phase['activity']}")
print(f" Output: {phase['output']}")
Common Mistakes
Mistake 1 โ Adopting BDD as a testing technique instead of a collaboration practice
โ Wrong: “We adopted BDD โ our testers now write all tests in Gherkin instead of code.”
โ Correct: “We adopted BDD โ our product owners, developers, and testers discuss acceptance criteria together using concrete examples before development starts. The examples become Gherkin scenarios that are automated and serve as living documentation.”
Mistake 2 โ Writing scenarios after development instead of before
โ Wrong: Developer builds the feature, then tester writes Gherkin scenarios to retroactively document what was built.
โ Correct: Three Amigos discuss and write scenarios before development. Developer uses scenarios as acceptance criteria. Tester automates the scenarios as development progresses.