BDD-Behavior Driven Development

What is BDD testing ?


BDD is one of the techniques of Agile Software Development and is extension of TDD (Test Driven Development).In TDD, developers (1) write Unit tests and watch them fail, (2) develop the feature to make the tests pass, (3) refactor the code to make it stronger, and (4) repeat the cycle. In BDD, teams do this same loop with Feature tests (a.k.a “acceptance” or “black-box” tests) as well as Unit tests. Advantage of BDD testing is stories are written in layman terms(Gherkin) ,even a non-IT person can easily write and understand which describes the expected behavior of application.





Aligning on precisely what to build is a challenge when developing innovative systems. In addition, new ideas are difficult to communicate with the diverse set of stakeholders.

Above figure illustrates the three perspectives required to clearly define solution behavior:


  • Customer-centric stakeholders understand customer and business needs and the relative desirability and viability of new requirement.

  • Development-centric stakeholders understands the solution space and technological feasibility.

  • Test-centric stakeholders consider the exceptions, edge cases, and boundary conditions for the new behavior.

  • Together this group reaches alignment on exactly what to build to reduce the rework associated with building the wrong thing and to accelerate the flow of value.


What is Gherkin?


Gherkin is a Business readable , Domain Specific Language created especially for behavior scenarios.

Gherkins serves as two purposes : serving as project’s documentation and automated tests.

The use of Gherkin allows technical and non-technical project stakeholders to participate in authoring the feature descriptions and therefore tests. Those descriptions serve as a base for the work of both developers (specification and feature description) and testers (test steps).

The main keywords used in Gherkins language are:

· Feature

· Scenario

· Given – Some given context (Preconditions)

· When – Some action to be performed (Actions)

· Then - Outcome/consequence after the above step (Results).


Let us look at a simple example of adding two numbers in calculator using Gherkin


Feature: Calculator

Scenario: Add two numbers

Given I have entered <First> in the calculator and I have entered <Second> into the calculator

When I press add

Then the result should be <Result> on the screen


Examples:

| First | |Second| |Result|

| 100 | | 20 | | 130 |

| 05 | | 40 | | 45 |

| 07 | | 14 | | 21 |

36 views0 comments

Recent Posts

See All