Tutorial 4: Background in CUCUMBER


Hello Everyone,

In this Series we will try to understand that how to organize our scenarios using background. 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, 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:

backgr

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

This entry was posted in Scala and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s