Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify the feature file location in cucumber

I have created some cucumber test steps and a small Cucumber test case, which I run with JUnit like so:

@RunWith(Cucumber.class)

public class FuelCarTest {
    //executs cucumber steps in the class FuelCarSteps
}

The Cucumber features files are now automatically loaded from the classpath location, src/main/resources/<package-name>/*.feature

I could like to know how I can tell cucumber the location of my feature files, because I need it to load them from a location outside the classpath (e.g. data//).

like image 581
lanoxx Avatar asked Dec 13 '12 13:12

lanoxx


People also ask

How do I change the feature file path in Cucumber?

there is the @Cucumber. Options annotation, among setting the report output format and location, it also allows setting the location for the feature files.

Where do you put Cucumber feature files?

In Cucumber, an example is called a scenario. Scenarios are defined in . feature files, which are stored in the src/test/resources/hellocucumber directory (or a subdirectory).

How does Cucumber Find feature files?

By default Cucumber will load all files in the 'features' folder in the root directory (recursively). If you want to use a different location you can run Cucumber with the command 'cucumber myfolder' which will look for features in a folder called myfolder in the project root. By default, cucumber loads all *.


1 Answers

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/"
)
like image 107
lanoxx Avatar answered Oct 24 '22 00:10

lanoxx