BDD- Behavior Driver Development is basically a software development process that originated from TDD, which is having tests written in plain English(Gherkin) and explained as behavior of application. Each Test/Scenario is written in such a way that the user can relate and understand those tests with the application. The simplicity is one of the major benefits of BDDeven a business or stakeholders of the project can understand how software automation is executed. Another interesting aspect about BDD is that it helps to build an application from the end user’s perspective.
The idea is to describe how the application should behave in a very simple user or business-focused language. BDD’s business-focused perspective on application allows teams to create living documentation that is easy to maintain and can be consumed by all team members, including testers, developers, and product owners.
A typical mature BDD process is made up of below key activities:
- Discover
- Define
- Automate
- Deliver
Feature File Creation:
Any BDD testing tool – (SpecFlow, Cucumber etc.) reads the Instruction (Test Steps) written in plain English text in the feature file. It allows functional validation and acceptance testing that is easy to read and understand.
It uses Gherkin as a language. Gherkin works using a set of keywords in English which is used by developers in test scripts.
A feature file consists of the following keywords :
- Feature − Name of the new feature to be test.
- Description − Describe about feature under test.
- Scenario – Your Test Scenario (Objective).
- Given − Prerequisite for the test steps to get executed.
- When − Specific conditions should be matched in order to execute the next step.
- Then – It is a kind of validation step when the “When” Statement getting executed.
Implementation of BDD Testing
Feature : Place an Order from Flip-kart.
@Sanity
Scenario: Verify customer is able to place an order
Given I login to application
When I select my product and add it to cart
And I checkout my product from cart
Then Order should be placed successfully
Why/Benefits BDD?
- Communication is the primary advantage. The gherkin is the common language that the PO and development team speak. Also, the gherkin language becomes the checklist that satisfies the expected criteria and the automated tests.
- High Visibility – The end result of BDD is the test report that contains a number of passed PBI’s and failed PBI’s, the team gets strong visibility into the PBI’s progression
- Functionalities defined with descriptive scenarios
- Scenario steps are reusable in the feature file
- Understandable test scenarios for non-technical people
- You can easily solve whether the reported issue is a bug or an improvement