Reading Time: < 1 minute
Hello Everyone, In this Series we will try to understand that how to organize our scenarios using Background in CUCUMBER. When we write multiple scenarios within single feature file with repeated steps. Starting steps which are common in all the scenarios can be pulled out into a Background test steps.
Using Background in CUCUMBER, we can make the feature file more readable and less complex in lieu of writing steps over and over again for each scenario.
Here is an example of background:
When we execute the feature, at run time, the steps in Background are executed in the beginning of each scenario.
Advantage of background :
- If we want to change those steps, we have to change them in only one place.
- when we write or read the scenarios we can focus on the what is unique and important in that scenario.
- Reduces complexity and increases the readability of feature file.
Points to remember:
- always use simple steps that will be useful for User
- Steps short be short
- Keep the steps vivid
You can read the previous post related to Tags in CUCUMBER: here