Overriding Cucumber Options

There are several ways you can set the options used to control how Cucumber runs your features. Learning how they interact is useful if you want Cucumber to behave differently depending on how you invoke it. Let’s look at the various ways you can supply options to Cucumber and how they interact.

How Cucumber Overrides

Cucumber options initially get set by the arguments you provide to your runner—either directly on the command line for cucumber.api.cli.Main or using a @CucumberOptions annotation for the JUnit or TestNG runners.

Cucumber then looks to see if any option overrides have been provided. It looks in the following three places:

  1. The OS environment variable CUCUMBER_OPTIONS

  2. The Java system property cucumber.options ...

Get The Cucumber for Java Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.