sri sri - 2 months ago 21
Java Question

execute multiple cucumber feature files

When I submit a single feature file it works perfectly. I want to pass features folder path which has multiple feature files into runner script. Can anyone help to execute multiple feature files?

All feature files have same steps but data is different and file name is different.

@RunWith(Cucumber.class)

@CucumberOptions(format = {"pretty"}, features =
"C:\\TESTER\\Execution\\uidata\\featurefiles\\",
glue={"com.test.auto.stepdefs"},dryRun=false)

public class CucumberTest {

}


I appreciate you help.

Answer

You can also use Cucumber Command-Line Interface Runner (CLI Runner) cucumber.api.cli.Main and pass the path to the folder containing feature files as command line option.

Example:

java cucumber.api.cli.Main --glue com.my.stepdefn --plugin html:C:\testreports C:\features\ 

com.my.stepdefn is the package having the cucumber step definitions

C:\features\ is the folder containing the feature files

C:\testreports is the folder where the cucumber html report will be generated.