sri
sri

Reputation: 55

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.

Upvotes: 5

Views: 23168

Answers (3)

Himadri
Himadri

Reputation: 150

This is for Java-Cucumber users :: Multiple Features are 1.Smoketest 2. Logintest Then your Junit runner java file should look like

@RunWith(Cucumber.class)    
    @CucumberOptions 
    (features = "src/test/java/testStep/",#Path for the Feature files Folder.Given you have smoke.feature and login.feature files present in the Path#
    plugin ={"pretty","html:reports/test-report"},#Path for the Reports Html Folder#
    tags= {"@smoke,@login"})#Declaring multiple Feature names of files#

-- Cheers

Upvotes: 1

Ramesh C
Ramesh C

Reputation: 36

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.

Upvotes: 0

Eugene S
Eugene S

Reputation: 6910

The features path must be relative to your project classpath. For example it can look like this:

@CucumberOptions(features = {"classpath:features_folder1", "classpath:features_folder2"}, ...)

or

@CucumberOptions(features="src/test/resources")

Upvotes: 4

Related Questions