Consider I have below feature files:
Login.feature
Feature: Login on website
Scenario: Login verification on site
- Given Navigate to site login page
- When User enters username 'admin1'
- And User enters password 'admin1'
- And User clicks on login button
- Then User should not be able to log in successfully
Home.feature
Feature: Welcome Page Verification
Scenario: Verify the page that comes after login
- Given Login is successfully done
- When The page after login successfully appears
- Then The test is done
In Home.feature file, I need to execute Login.feature first and then call home.feature. So when i execute home from my runner test it will in turn execute login and then home.
RunnerTest.java
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(strict = false, features = {
"src/test/resources/Features/Home.feature",
}, glue = { "tests" }, plugin = "html:target/cucumber-reports", format = { "pretty",
"json:target/cucumber.json" }, tags = { "~@ignore" })
public class RunnerTest {}