Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Cucumber: Take @CucumberOptions from external source like a property file

Is it possible to take cucumber option values from a java .properties file?

In this SO post, it shows that it is being passed from CLI.

Here's my sample class:

@RunWith(Cucumber.class)
@CucumberOptions(
        features = {"resources/features/"},
        glue = {"classpath:com/"},
        tags = {"@foo, @bar"}
)
public class UITestRunner {

}

Instead of hardcoding the tags here, I'd like to take it from a property file. Any help is appreciated!

like image 1000
iamkenos Avatar asked Jul 14 '17 05:07

iamkenos


1 Answers

Cucumber will initially look for arguments provided by cucumber.api.cli.Main or @CucumberOptions

But you can override them providing (in this particular order):

  1. The OS environment variable CUCUMBER_OPTIONS
  2. The Java system property cucumber.options
  3. The Java resource bundle cucumber.properties with a cucumber.options property

Once one of described above options is found, it will be used. Overrides are provided in a variable (or property) called cucumber.options or CUCUMBER_OPTIONS. All values, except plugin arguments will override values provided by cucumber.api.cli.Main or @CucumberOptions. Plugin option will add up to the plugins specified by cucumber.api.cli.Main or @CucumberOptions.

like image 116
fg78nc Avatar answered Oct 24 '22 01:10

fg78nc