BDD Framework

BDD Framework is a software development approach in which requirements are defined based on the behavior that the user expects to experience while interacting with the software. It reduces the gap between business analysts and technical people through improved communication.


BDD Testing

It is evolved from TDD (Test Driven Development) where tests are written ahead of the code, but in the case of BDD, tests are user-focused and based on the system’s behavior.

Behavior-driven development makes use of a domain-specific scripting language which further converts the structured statements into executable tests. The acceptance criteria for a given test is used to validate the functionality

BDD focuses on:

  1. The starting point of the test
  2. Scope of test
  3. Test parameter
  4. Acceptance criteria of the test
  5. Failed Tests


BDD Key Aspects

It encourages developers to focus only on the required behaviors of the software.

It helps to avoid the induction of excessive code or unnecessary features.

It encourages collaboration between developers, testers, product owners, business analysts to build a shared understanding of the problem to be solved.

It produces system documentation that is automatically checked against the system’s behavior.

It helps to identify the key scenarios for user stories and eliminate ambiguities from requirements.

It helps to keep all the stakeholders on the same page.

 

How Business-Driven Development (BDD) works?

Behavior-driven development moves around conducting the behavior-specific tests, or functional requirements that emphasize on executable scenarios for the application. The below steps defined the BDD process:

  1. Identify goals in order to meet business requirements. This includes understanding the software in order to achieve a business perspective. This business goal drives the complete project. An ideal business goal is Specific, Measurable, Attainable, Relevant, and Time-bound (SMART).
  2. After the goal and timeline are defined, the next step is planning. It outlines all the alternative ways to meet the decided goals by analyzing user behavior.
  3. The next step is the prioritization of features, backlogs, etc. which is done by using value and complexity analysis. Value analysis helps to quickly determine low-cost, high-value features in the backlog. Complexity analysis helps to identify the correct development and collaboration approach of the project as well as individual features.
  4. Derive the technical feature from the specifications. This includes defining business rules, use cases, etc.
  5. In the next step, the descriptions of the technical features are used to generate requirements in GWT (Given When Then) format. Acceptance criteria for each requirement are defined. Then statement defines the acceptance criteria.
  6. Behavioral tests are created for each requirement before development starts. Initially, before development begins, it is expected all of the behavioral tests will fail, but as the development of the product progresses, the tests will begin to pass. Once all of the behavioral tests are considered passing, the product is ready.

 

BDD Testing Example 

Given‘ describes the initial context for the scenario

When‘ describes the action that the actor in the system going to perform

Then‘ describes the expected outcome of that action

Let see below the structure of the requirement in BDD from the below example

Given user is in the login page of Gmail account

When user enters correct email Id and password

Then user will be successfully logged in to its account


Advantages of BDD

  1. Better communication between developers, testers, and product owners.
  2. Acceptance criteria are defined prior to the development
  3. It focusses on verifying the behavior rather than tests.


Disadvantages of BDD

  1. Prior experience of TDD is required, before starting with BDD.
  2. BDD is incompatible with the waterfall approach.
  3. BDD may not be effective if the requirements are not properly specified.
  4. Testers using BDD need to have sufficient technical skills.