Article
Behavior-Driven Development: Examples, Tools, and Automation
Learn how BDD works, write better Given/When/Then scenarios, compare testing frameworks, and evaluate automation options for your team.

Behavior-driven development (BDD) gives business and delivery teams a shared way to define how software should behave before coding starts. Instead of leaving a short requirement open to different meanings, the team works through real examples. A discount rule may sound simple until someone asks if shipping counts toward the minimum order. BDD brings that question into the discussion before it reaches the code.
Many teams write these examples in Gherkin using Given, When, and Then. Some scenarios later become automated tests against the real application. The automation choice affects how much test code the team has to write and maintain. This guide follows one checkout rule from first discussion to automation, then compares BDD tools and closes with an evaluation checklist.
What Is Behavior-Driven Development?
Behavior-driven development is a shared practice where business stakeholders, developers, and testers define expected software behavior through clear examples before development starts. The examples describe real situations instead of broad requirements. Everyone discusses the same rule before anyone writes code.
Take a promotion that starts at $100. A $120 order is an easy case, but $99.99 exposes the boundary. An expired promotion brings another rule into the discussion. The team now has clear cases to settle before development begins.
People often search for "BDD testing" or "BDD in software testing," but testing covers only the last part of the BDD methodology, after the team has agreed on what correct looks like. A scenario is a written statement of intent. Quality is the distance between that intent and what reaches customers, and the test's job is to show how wide that distance is.
How BDD Works: Discovery, Formulation, and Automation
BDD usually moves through three practices: discovery, formulation, and automation. Discovery brings the team together to agree on business rules and examples. Formulation turns those examples into clear scenarios, while automation connects selected scenarios to running tests.
Cucumber describes BDD using the same three practices. It treats them as small, iterative parts of development rather than a separate testing process. This also makes BDD a natural fit inside Agile sprints, where teams can work through behavior one story at a time.
Discovery: Agree on the Business Rules
Discovery starts with a story and the rules behind it. The people involved discuss real cases instead of guessing what a short requirement means. Open questions stay visible until the team agrees on an answer. Example Mapping is one common way to record that discussion, and a promotional discount might look like this:
The question in the final row can change the code. One developer may use the merchandise subtotal, while another may include shipping. Product can settle the rule before either version reaches the application. The discussion may also uncover an expiry rule that the original requirement never mentioned.
Formulation: Turn Examples Into Clear Scenarios
Formulation turns agreed examples into written scenarios. Each scenario states the starting condition, the action, and the expected result in business language. Product owners can review the scenario without reading automation code. The wording stays close to the rule being discussed.
“The discount is applied” is weak because the result is still open. “The discount is $12” gives the test a clear value to check. Product and testing teams now have the same target.
Interface details usually stay out of the scenario. A button name may change while the discount rule stays the same. The test layer handles the button, leaving the scenario focused on business behavior.
Automation: Connect Scenarios to Running Tests
Automation connects selected scenarios to the real application. Traditional BDD tools usually map Given, When, and Then steps to coded step definitions. Developers or SDETs write the code that performs each action and checks the result.
A feature file cannot click through checkout on its own. The code underneath it talks to the application and works with the required test data. As the suite grows, the amount of test code grows with it. That workload becomes part of the tool choice.
BDD Example: Verifying a Checkout Discount
Illustrative rule: SAVE10 gives a 10% discount on eligible merchandise subtotals of $100 or more. Shipping and tax are excluded. Expired codes are rejected.
Feature names the behavior under discussion, each Scenario captures one example, and Given sets the starting state. When records the action, Then states the expected result, and And continues the previous step type.
Gherkin also supports options such as Background and Scenario Outline. Scenario Outline works well when the same rule needs several data values. Background can hold setup shared across several scenarios.
The two scenarios above still leave gaps. The exact $100 boundary needs a result, and an expired promotion needs one too. The order record also matters after checkout. A small matrix keeps those cases visible:
A success message isn’t enough for the main checkout test. The page could show “Discount applied” while the merchandise total is still wrong. Checking the $12 discount gives the test a real business result. The order record also matters when checkout passes that value into another system.
Not every case needs a browser. Promotion eligibility may fit better at the service level. The complete checkout test can stay focused on behavior that crosses the interface and the saved order.
BDD vs. TDD vs. ATDD
BDD, TDD, and ATDD all bring expected results into development early, but they work at different levels. TDD sits closest to the code. ATDD focuses on agreed acceptance criteria, while BDD uses examples that business and delivery teams can discuss together.
The practices can sit inside the same feature. Unit tests may cover calculation logic while BDD covers the business rule around that calculation. ATDD can overlap with many of the same acceptance cases. Teams do not need strict walls between them.
The SAVE10 example shows how the layers can meet. Unit tests can cover the 10% calculation and rounding. BDD scenarios can cover the promotion threshold and expired codes. A small number of end-to-end tests can then check checkout and the stored order.
BDD Tools and Automation Options
BDD tools differ in how they connect written behavior to running tests. Code-based tools give development teams direct control over the test code. Agent native testing removes much of that coding work and keeps the suite current as the application changes. The right choice depends on the team and its current test process.
Cucumber
Cucumber is one of the best-known tools linked with Gherkin. Feature files can sit beside application code and connect to coded step definitions. Cucumber supports several programming languages, including Java and JavaScript.
Cucumber does not control a browser by itself. Teams often pair it with Selenium or Playwright. Developers or SDETs write the step definitions and maintain the application interactions behind them.
Reqnroll
Reqnroll is an open-source BDD tool for .NET and the community successor to SpecFlow. SpecFlow reached end of life on December 31, 2024. Reqnroll provides migration guidance for teams moving existing projects.
Teams coming from SpecFlow will find a familiar working model. They still need to check their bindings and any plugins after the move. Reports also need real project testing before you leave the old setup behind.
Behave
Behave brings Gherkin-style testing to Python projects. Feature files connect to Python functions that perform the test actions. Python teams can keep that work close to the rest of their codebase.
Behave maps written steps to Python functions. The project still needs its own application interaction code and test data. It fits teams that already use Python for testing and want direct control over the code.
Functionize Studio
Functionize Studio takes a different route with agent native testing. Testers describe the behavior in natural language, and Studio builds the test without traditional step definitions. It runs tests across browsers and keeps the suite current as the application changes.
Studio works from plain-language intent rather than .feature files. Teams that rely on Gherkin as the executable source can test that fit during a trial. Studio also has a Free plan, so teams can try the workflow without starting with a budget request.
How to Choose a BDD Automation Approach
Choose a BDD automation approach based on how much test code your team wants to own and maintain. Code-based tools fit teams that already have strong developer or SDET support, while agent native platforms fit teams trying to reduce authoring and repair work. The best choice matches your current workflow, test volume, and maintenance burden.
Choose based on your constraints: A code-owned setup makes sense when the current feature-file process works, and the team has time to support it. A testing platform fits better when authoring or maintenance keeps useful coverage behind the product. Both models can also run side by side during a pilot.
A new tool does not need to replace a healthy suite. The clearest comparison often comes from a gap the current setup handles poorly. The same business flow can run through both approaches. Maintenance hours and failure quality then give the team something real to compare.
Where BDD Automation Becomes Expensive - and How to Control It
BDD itself is rarely the expensive part; the cost grows around the automation that supports it. Step code can pile up, UI changes can break interactions, and duplicate steps often create extra maintenance. Shared test data adds another problem when tests pass alone but fail during a full regression run. Click-heavy scenarios make this worse because small interface changes can break tests even when the business behavior still works.
Test placement and weak assertions can add even more work. Simple business rules often fit better at the service level, while end-to-end tests make more sense for complete user flows. Tests should also check the real business result, such as the $12 SAVE10 discount, rather than trusting a general success message.
Reports create their own drag. When a failed run doesn't show which step broke or who owns the fix, someone loses an hour deciding whether it's a flaky selector or a real regression.
A moved promo field and a wrong discount are very different failures. The first belongs to test maintenance, while an $11.99 discount may point to a real product defect. The moved field is a flaky selector problem. The $11.99 discount is a regression. A testing approach needs to keep those cases separate: signal, not noise. The Studio walkthrough below uses the SAVE10 example to show the difference.
From Agreed Behavior to Automated Verification With Functionize Studio
The SAVE10 rule can move into Studio without turning each BDD line into coded step definitions. The tester starts with the behavior already agreed during discovery. A plain-language instruction can state the order value and expected discount. One version might read:
Studio turns that request into test steps with clear verifications. The tester reviews the generated test before relying on it. A check for only “Discount applied” would be too weak here. The amount must match the business rule.
Testers can also ask Studio what to test. It can surface other cases around the rule. A boundary value may be missing from the first discussion, or an expiry case may need its own check. The team still decides which cases belong in the final test set. Studio turns the approved behavior into running tests.
The finished test can run across browsers and keep evidence from each step. Data-driven testing can reuse the same flow for other agreed values. Several cases can share the same business flow without separate copies of the test.
A moved promo field tests the other half of the promise. Studio re-identifies the element and heals the interaction mid-run. The expected $12 discount stays unchanged.
A bad calculation gets a different response. Suppose a code change returns $11.99 instead of $12. Studio fails the run where the amount differs and diagnoses the failure as a real regression, not a broken interaction. The team sees which part of the test failed.
People still own the definition of correct behavior, which risks matter, and the release call. Studio takes test creation and maintenance off their plate. You direct. Agents execute. The standard is yours.
Enterprise Evaluation Checklist and Pilot
A small pilot gives the team a better comparison than a polished demo. The workflow needs a result everyone can judge without debate. Checkout works well, but another business flow can work too. A narrow scope also makes the time spent around each test easier to measure.
The pilot needs to test both harmless product changes and real defects. A UI change shows how the tool handles normal interface movement, while a planted defect checks if it still catches a real product problem. Authoring time, repair work, and failure quality then give the team a practical basis for comparison.
If your team has access or data requirements, add them to the pilot criteria so they're tested alongside everything else.
Studio's Free plan includes five parallel runs, enough to pilot a real workflow. A team can test one business flow before making a larger decision. The same UI-change test and planted defect can give that trial clear success criteria.
Frequently Asked Questions
Is BDD the Same as Gherkin?
No, BDD is the practice of agreeing on software behavior through concrete examples, while Gherkin is one popular way to write them down. Teams can also run BDD discussions with tables or plain text.
Can BDD Work With Agile?
Yes, BDD fits well inside Agile because teams can discuss behavior one story at a time before development starts. The agreed examples can stay with that story through development and testing.
Does BDD Replace Unit Testing?
No, unit tests usually check smaller pieces of code, while BDD scenarios focus on business behavior. The same feature can use both types of tests without either one replacing the other.
Can BDD Be Used for API Testing?
Yes, a BDD scenario can run at the API level instead of through a browser. API checks often suit business rules that don't require a full user flow.
What Replaced SpecFlow?
Reqnroll is the community successor for .NET BDD projects, after SpecFlow reached end of life on December 31, 2024. It publishes migration guidance for teams moving existing SpecFlow suites.
Can AI Help Automate BDD Scenarios?
Yes, AI-based testing tools can turn plain-language behavior into running tests and handle test maintenance. People still decide what correct behavior means and when expectations change.

