Specify the feature file location in cucumber
I found the solution,
there is the @Cucumber.Options annotation, among setting the report output format and location, it also allows setting the location for the feature files.
@Cucumber.Options(
format = {
"pretty",
"html:target/cucumber-html-report",
"json-pretty:target/cucumber- report.json"
},
features="features/"
)
I have placed all feature files in test/resources/features
and added my feature file location with class path. Here is my cucumber run file.
@RunWith(Cucumber.class)
@CucumberOptions(
monochrome = true,
features = "classpath:features",
plugin = {"pretty", "html:target/cucumber-reports",
"json:target/cucumber.json"
}
)
public class MyTests
{
}
This will pick all feature files inside the folder features. If you want to have a subfolders you can add that too by just replacing the line as shown below.
features = "classpath:features/DEV"
If only one particular feature file, it should be like this
features = "classpath:features/DEV/SmokeTests.feature"