Selenium Cucumber Java BDD Framework 10 | Background | Step by Step
1 - What is Background
2 - Why to use Background
3 - When to use Background
4 - How to create & use Background - Step by Step Demo

Useful Tips

What is Background?
A Step or a group of steps that are common to all the scenarios in a feature
Is defined once in the feature
Runs before every scenario of the feature

Why use Background?
To avoid repeating the common steps in every scenario
For better readability & maintenance
Unlike hooks, background is visible to the readers of the feature file

When to use Background?
Whenever there are common repeating steps in a feature
When you want the common steps to be visible to the readers

DEMO
How to use Background

  • Step 1 - Create a new or use an existing Feature File
  • Step 2 - Create the steps for the scenario in the feature file
  • Step 3 - Create new or use an existing TestRunner class
  • Step 4 - Run the test runner file
  • Step 5 - Create a background section and add common steps
  • Step 6 - Run the test runner file and check execution of the background

Useful TIPS
You can only have one set of Background steps per Feature
If you need different Background steps for different scenarios, consider breaking up your set of scenarios into more Features
Use background so that all stakeholders can understand the scenario
Keep the background section short

#java #selenium #testing #programming #developer

Selenium Cucumber Java BDD Framework 10 | Background | Step by Step
2.10 GEEK