BDD, Behaviour driven development is an Agile software development process, where in the software teams work to fill the gap between business people and people from technical background by the means of below tasks:
- Encouraging cooperation across roles to build shared understanding of the problem to be solved
- Working in small iterations and fast to increase flow of value as well as feedback.
- By producing system documentation that is automatically checked against the system’s behaviour
The activity has three steps, iterative process:
- It is done by taking a small upcoming change to the system(as user story) and talk about concrete examples of the new functionality to explore, discover and agree on the detailed information of what’s expected to be done.
- By documenting those examples in a way that it can be automated and check for agreement.
- Finally implement the behaviour described by each document
These practices can be called as Discovery, Formulation, and Automation
Discovery– what it may do:
The goal of BDD is valuable, writing software and it helps teams to have a right communication at the proper time as we can minimise the time for meetings and utilise the time to produce amount of valuable code.
Formulation– what it should do:
Here we can formulate the every example of discovery sessions as structured documentation which gives us a quick way to confirm that we really have shared understanding of what to build.
Automation-what actually it does:
By taking one example at a time we can automate it by connecting to the system as a test. Automated examples work like guide-rails and helps us to keep our development work on track.
BDD Association with cucumber:
The cucumber documentation states as, BDD narrows the communication and also gap between team members to foster better understanding of the customer and encourage continuous communication with real world examples.
Cucumber is a tool based on Behaviour driven development methodology. The main goal of BDD is to make many different projects so that Business analyst, quality assurance, developers understand the application without diving deep into technical aspects.
How to setup selenium cucumber Java BDD Framework?
- Goto eclipse to create a project
- Create a Maven Project in all latest version of eclipse, maven plug in is installed so that option is found.
Give the group Id and artefact id and click finish
Finally the project is created
We have feature file and we have project structure:
We have pom.xml where maven dependencies are installed and selenium java dependencies have to be added
Selenium java dependencies from internet.
Now create a feature file and add scenario. Goto features folder.
Click new then select file give file name to test login
Write the scenarios and arrange in pretty format
3. Run the feature file
Create the test runner file then write the code. If we run the testrunner class then we can see the output as scenario got passed. By creating the testrunner class we can run the feature files as per our requirement whatever features we want along with reporting, we can add and test it.
Association of BDD with Agile:
The Behaviour Driven Development is a way of writing the proper requirements which can be automatically turned into code for agile developers to automate testing that feature.
The agile requirements:
User stories became more and more famous tool to write requirements. The standard format of user stories is as below:
As a[user role]
I want [some action]
Quite often user stories look like
As a user
Want to login into application
So I will be logged in
These user stories for simple requirements as authentication is waste of time and also shows the most common mistake which was observed in many teams starting adventure with BDD or Agile requirements.
How to write a good user story using 3 components?
- Who requires it? What is required? and Why is it required? these questions provide context for the user story
- Acceptance criteria, this specifies the required functionality for the particular user story
- Supporting models, these are supporting documents for analysis models.
Here, Jack is a BA working with a client running a Restaurant called “Meals on Wheels”. They need a mobile app which has a feature for customers to book a table. Here we have to write a proper user story which involves features like:
- Table booking
- Confirmation message once booking is confirmed in the system
- Display only available time slots to customer.