Search code examples
seleniumcucumber

How to run multiple feature files using the cucumber runner class?


Using the below line of code, all scenarios mentioned in login.feature can be executed.

@CucumberOptions(features= "src/main/resources/publish/login.feature", format = {"pretty"} )

If I have to execute multiple feature files, how do I define? Assuming if I define as below, features mentioned in publish folder would be executed.

@CucumberOptions(features= "src/main/resources/publish", format = {"pretty"} )

If I have to run multiple features and scenarios inside it, how do I define? Do i have to create multile cucumberRunner classes or i can define in one class file.


Solution

  • You can do it by defining tags value in cucumber option(considering that you have already grouped those scenarios in feature files)

    Eg: features="src/test/resources/FeatureFiles",tags="@feature1scenariogroup1,@feature2cenariogroup2"

    Defining Tags Inside Feature File:

    Feature: My Feature File
    @smoke 
    Scenario: Login
    Given I open "FireFox" browser
    When I navigate to Sectionone "Home" page
    And i do something
    Then I Validate Something  
    
    @regression 
    Scenario: Compose Email
    Given I open "FireFox" browser
    When I Do An Action
    
    @OnlyOneTime
    Scenario:Send Email
    ....