What is BDD?

BDD Helps You Find Bugs Before They Find You!

Behavior Driven Development creates a shared understanding of how an application should behave by discovering missing requirements based on concrete examples. This is how bugs & misunderstandings are prevented.

Shared Understanding of Requirements

Everyone knows exactly what to do

Concrete examples of expected system behavior foster a shared understanding by being detailed enough for developers and testers while still making sense to business participants.

Developer

Teams using BDD are much more confident that they won’t break the code, and have better predictability

Tester

Focus on writing tests in natural language instead of building complex testing-code

Product Owner

Collaborate with your team easily within a web browser

3 Phases of BDD Development

1

Discover

Specify collaboratively with examples
2

Formulate

Write Gherkin test cases in natural language
3

Automate

Avoid regression by automating test cases

1 Discover

Discovery refers to a structured, collaborative practice for specifying software requirements with examples. The process of Discovery is also known as a “Specification By Example workshop.” Discovery aims to overcome the blind spots of the “unknown-unknowns” in software development and reduce the learning bottleneck.

Developer

Focus on coding - understanding the needs of stakeholders

Tester

Focus on writing tests in natural language instead of building complex testing-code

Product Owner

A more streamlined collaboration with your team

2 Formulate

Formulation is the practice of turning key examples from Discovery into formalized documentation, such as the easy to read Gherkin scenarios.

Scenario: Simple search
 
When I search for '.NET BDD framework'
Then the list of found results should contain: SpecFlow

3 Automate

Automation is where formalized scenarios are turned into automated acceptance tests. Automated acceptance tests significantly reduce efforts for regression testing and provide immediate feedback when the specification documentation doesn’t match the system behavior anymore.

Developer

Implements step definitions
When I search for '.NET BDD framework'
Step definition for this step:
[When(@"I search for '(.*)'"]
public void WhenIPerformASimpleSearchOn( string searchTerm) {
var controller = new CatalogController();
actionResult = controller.search(searchTerm);
}

How Does SpecFlow Support BDD?

SpecFlow turns Gherkin scenarios into automated tests and helps teams bind automation to feature files and easily share the resulting examples.

Developer

Spend more time on coding feature-logic rather than debugging and explaining code.

Benefits for Developers

Tester

Apply your testing skills throughout the entire development cycle

Benefits for Testers

Product Owner

A single source of truth for better collaboration with the team

Benefits for POs

What is the difference between BDD and TDD?

BDD is TDD done right!
There are resounding similarities between BDD and TDD as they are both a testing method that requires developers to write the tests prior to writing the code to pass the tests. At its core, though, TDD is more focused on separately testing smaller pieces of functionality, whereas BDD is designed to test an application’s behavior from the end user’s perspective.
TDDREFACTORMAKE THETEST PASSWRITE AFAILING TESTBDDREFACTORWRITE AFAILINGFEATURETEST

BDD Pros and Challenges


BDD Pros

Collaboration

Allows for continued collaboration and increased visibility among the entire team.

User Satisfaction

By focusing on the needs of the business, you get satisfied users — which translates to customer loyalty and better business outcomes.

Fewer Bugs

Involving testers from the beginning means fewer bugs later.

Effectiveness

Since you extend the system in small increments, you can validate business values earlier and avoid unnecessary features. This prevents gold-plating and makes the overall implementation of the system more effective.

Faster feedback

Example scenarios describe focused, granular changes to the system under development. This enables teams to evolve the system in small steps while keeping it potentially shippable, allowing for shorter release cycles and faster feedback.

Code Quality

BDD has a positive impact on code quality: it promotes emergent design that ensures loosely-coupled, highly cohesive architecture and avoids over-engineering.

BDD Challenges

Learning Curve

As with any new methodology or practice that is introduced to new teams, there is a learning curve that requires the entire team to put time and effort into learning a new practice. Adopting a new practice may be a big challenge for some teams. 

Initial time overhead

Creating and maintaining the feature files and scenarios requires an overhead investment of time and effort. In small projects, it may not be worth it, but in projects that have many iterations, you’ll definitely see a return on that investment.

Boost Your Development by Practicing BDD

Start using SpecFlow now