I'm facing issues with reusing feature file. I have added checkout feature file to place an order. My purpose is to reuse this feature file in other scenarios as well?
Feature: Checkout
@checkout
Scenario Outline: checkout
Given I navigate to application home page
When I search for keyword "<Search>"
When I click on searched result "<Search>"
Then I verify the checkout page "<Search>"
When I click on Get Tickets button
When I enter the fields values of buyer and Ticket information
And I enter the payment details and click on Pay Now button
Then I verify the payment will be successful
Examples:
|Search|
|Test Event|
For eg: I have created another scenario "checkout with applied discount code" and it's reusing few steps from "checkout" feature file(bold text)
Feature: Checkout with applied discount code
@discount
===============================================
**Given I navigate to application home page
When I search for keyword "<Search>"
When I click on searched result "<Search>"
Then I verify the checkout page "<Search>"
When I click on Get Tickets button
When I enter the fields values of buyer and Ticket information**
=================================================
When I apply "CODE10" discount code
And I enter the payment details and click on Pay Now button
Then the discount will be applied on order total
Examples:
|Search|
|Test Event|
I have added reusable steps in common file so that I don't have to create separate step file for both feature files.
Now framework is expanding and I need to reuse "Checkout feature" file in other scenarios as well.
Options I have in mind:
Use checkout feature as a background step in new feature file: Problem Background step will have 8-10 lines.
Refractor feature file to exclude implementation details like click, search , enter values and create methods in page file and reuse those methods in new feature file.
Need guidance on how to approach reusability so that I don't have to refractor code multiple times?
Any other ways to reuse feature file?