Reusing Background steps in multiple feature files | Selenium Forum
N
Nazar Kani Ahamed Nainar Posted on 01/10/2021

Feature1.feature

@Feature 1
Feature: Data validation


Background:
Given Make a connection to DB

Scenario Outline: Prepare the SF data quality check query and extract the data 
When Prepare the  SF query with date range "<startdate>","<enddate>"
Then Extract the SF data in an excel document "<startdate>","<enddate>"

Feature2.feature

@Feature 2
Feature: Data validation


Background:
Given Make a connection to DB

Scenario Outline: Prepare the DF data quality check query and extract the data 
When Prepare the  DF query with date range "<startdate>","<enddate>"
Then Extract the DF data in an excel document "<startdate>","<enddate>"

 

Both Feature 1 and Feature 2 uses the same background. The test runner gives me an initialization error since both the feature files have the same name, "Given." How can I reuse here by keeping the Given step in one place instead of giving different names in each Feature file? Please advise.


A
Ashish Replied on 07/10/2021

if both the feature files are linked to the same glue code then you can try giving background in 1 of them


Related Posts