Skip to main content

Cucumber Options Features

Features option helps Cucumber to locate feature files. It Identifies either a URI or a directory containing feature files. It also identifies a specific feature or scenarios and examples (pickles) in a feature.

When no feature path is provided, Cucumber will use the package of the annotated class. For example, if the annotated class is com.examle.Runner then features are assumed to be located in com.example.

Method Signature

  • String[] features()
  • default {};
  • Returns: list of files or directories

Example: @Cucumberoptions Features

@RunWith(Cucumber.class)
@CucumberOptions(
		plugin = {"pretty", "html:target/cucumber"},
		features = {"src/test/resources/features" }, 
		glue = {"com.pb.cucumbertest.stepdefinitions"}, 
		)

public class Runner {

}

In example given above my features files are inside src/test/resources/features. You can also write like this since our features files are inside src/test/resources

features = "classpath:features"
Submitted by tgoswami on September 13, 2021

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.