What is Behaviour Driven Development?
Behaviour Driven Development (BDD) is similar to Test Driven Development. In BDD, B represents the behavior of the software developed. Like Test Driven Development, in Behaviour Driven Development also, the code is first written in behaviour-driven way, and further production code written. But the main difference between Behaviour Driven Development and Test Driven Development is that in BDD the test is written in understandable descriptive English type grammar.
The primary benefit of Behaviour Driven Development is that it can easily be understood by a non-technical person also. BDD implemented on those behaviors only which related to the business outcomes and too helpful in avoiding the wastage of time and resources. Basically, in BDD, the behavior is described in single notation, which increases the communication and directly understandable by domain experts, testers and developers. BDD much more focussed on collaborating with business people and on the other hand TDD seem to be too technical.
How Behaviour Driven Development (BDD) Works?
Firstly the BDD process starts with a conversation between the product owner and users, actually what they need. Further, product owner, developer, and tester collaborated and understood the requirements and based on these requirements they define the structure scenarios. Then also based on these scenarios, the developer developed the tests, and the tester uses these scenarios as the basis for their experiments.
BDD is an improvement of The Three Amigos. These three amigos are the primary views to examine an increment of work –
- Before development
- During development
- After development
Those views are –
- Business – What type of problem trying to solve?
- Development – How to build a solution for a particular problem.
- Testing – What about this, what could happen?
BDD based on Given-When-Then formula used as a guide for writing the acceptance tests.
Where “Given” is any type of initial condition, “When” represents the occurrence of event/events and “Then” represents the expected outcome.
Behaviour Driven Development Best Practices
- Convert requirements into user stories.
- Implement valid user scenarios rather than the creation of test cases.
- Implement the specification behavior of a class rather than the unit test of a class.
- Follow approach of “Given When Then” involving a set of pre-conditions, event occurrence, achievement of outcomes.
How to Adopt this Approach?
- Library creation containing one or more tests and test steps and/or test scenarios referenced by the step definitions.
- Map behaviors in the feature file to the test steps.
- Behaviour Driven Development scenario executed, the test steps from the workspace into a new test to defines the scenario.
- Module executes the scenario via the automation tool. The results also reported back to the Behaviour Driven Development tool.
Benefits of Behaviour Driven Development (BDD)
- Clarity – In TDD there were test cases, but in the case of BDD, termed as scenarios. The focus of each situation is on the appropriate behaviors of the product. The behaviors in each scenario defined in simple, understandable language and further, if there is any conflict or confusion in it, then it can be cleared with a simple conversation.
- Strong Collaboration – BDD is collaborative. BDD involves the contribution of everyone from the customer to the tester. And anyone can write behavior scenarios written in plain language.
- Communication – As BDD is using plain language, so it is understandable by all from customer to tester which leads towards better communication and understanding between each other. And this also increases the teamwork capability.
- Business Value – BDD give importance to business values and needs. Because BDD gives priority to client requirements and further based on these requirements, also, the developer can provide efficient and better result because the developer has a strong understanding of how the client thinks.
Why Adopting Behaviour Driven Development Matters?
All over BDD is related to the essential features of the product, impacts of these features, and solution (what can be done to deliver these features). BDD helps in securing the extra efforts and reduce the wastage of time and resources too and also help prioritize what is essential. BDD works on these following step for effective product development –
- Requirements/Business goals.
- Impact/consequences of these goals.
- Solution to recover the impacts.
What is a feature file?
As already discussed previously that feature file should be of .feature extension which contains at least one scenario of the particular feature. And as already previously discussed that scenarios are some determinable business situations defined regarding Given-When-Then formula.
- Given some initial condition.
- Event Occurrence
- Then some expected outcome is achieved.
Top Behaviour Driven Development(BDD) Tools
When talking about tests, there are scenarios which are the way of explaining how a given feature should behave with different input parameters or in different situations. When talking about feature files, basically these are the text files. The extension of these type of files is .feature. These type of files opened by any text editor and can also be readable by any Behaviour Driven Development Tools like Cucumber, JBehave or Behat.
How useful was this post?