In most of the feature files, Scenario, Background, Data Tables and Scenario outlines are combined.
There is nothing special you have to do to combine these all in a single feature file. Declare and use them like you do while declaring multiple scenarios in a feature file.
Background will be common for all scenarios and scenario outline. Also, Scenarios and Scenario Outline will be independent of each other. Similarly, two Scenarios will be independent to each other.
Check below feature file:
@sanity Feature: Registration, Login and MyAccount Background: Title of Background Given I am on the home page And I follow "Sign in" link #Scenario Outline Example @scenariooutline Scenario Outline: Verify Login Functionality When I fill in "input[id='email']" with "<email>" And I fill in "input[id='passwd']" with "<password>" And I click on "button[id='SubmitLogin']" Then I should see heading "<heading>" Examples: | email | password | heading | | email@example.com | test1234 | My account | | firstname.lastname@example.org | test | Authentication | #Scenario Example @singleargument Scenario: Verify Forgot Password Functionality When I follow "Forgot your password?" link And I fill in "input[id='email']" with "email@example.com" And I click on "button[type='submit'] span i"
In above example,
- Scenario and Scenario Outline are independent of each other.
- Scenario and Scenario Outline both dependent upon Background because Background is common for both.