This is my cukesfile
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/test/resources/features/SellerApp/Dashboard/QuickSearch/Dashboard_QuickSearch.feature"},
plugin = {"pretty", "html:target/cucumber-report.html"},
glue={"steps"},
tags = "@run",
monochrome = true)
public class CukesFeaturesRunnerTest {
@BeforeClass
public static void executeBeforeTests() {
if (StringUtils.equalsAnyIgnoreCase(getConfigValue("env"), "ci")) {
System.out.println("Running test in headless mode");
Configuration.headless = true;
}
Configuration.headless = true;
Configuration.timeout = 12000;
Configuration.browserSize = "1600x900";
PluginsApi pluginsApi = new PluginsApi();
XolaApi xolaApi = new XolaApi();
if (StringUtils.equalsAnyIgnoreCase(getConfigValue("env"), "ci")) {
if (StringUtils.containsIgnoreCase(System.getenv("GO_JOB_NAME"), "traveler-app")) {
xolaApi.verifyX2TravelerAppIsRunning();
xolaApi.verifyX2SellerAppIsRunning();
} else {
xolaApi.verifyX2SellerAppIsRunning();
}
}
pluginsApi.getAllInstalledPluginId();
}
@AfterClass
public static void executeAfterTests() {
}
}
- The problem here is whenever I want to run any specific scenario, I have to give that feature file path value for features under cucumberOption.I want to make it in such a way I don't have to specify the path anymore, should pick up the scenario if @run tags are added to any scenario.
Cucumber will execute all features in a directory and its sub directories. So to execute all features in the
featuresdirectory you'd use.Then to select a single scenario, tag it with
@runand use:Or if you are on a recent version of Cucumber and using an IDE such as IDEA you can also select scenario to run from the UI.
Doing this does mean that the
@BeforeClassand@AfterClassare not invoked anymore. So you should replace these with the@BeforeAlland@AfterAllhooks from Cucumber(note: pull the code out of the runner and put with your other step definitions or Cucumber won't find them).https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-java#beforeall--afterall