Background in Cucumber

Background is used to make the feature file more readable and less complex by eliminating and grouping the common steps under the background keyword .

  1. Background should always be added before scenario & scenario outline
  2. It is always best practice to add pre-condition is background
  3. If there is a feature file and there are multiple scenarios which are having initial steps common then those can be moved to background.
  4. Background should be used wisely when actually it is required because for one scenario it may be required but it may not be required for another scenario in feature file as the background executes before every scenario in a feature file .

You may also like...