Cucumber Options
- saphinrao0
- Jun 4
- 4 min read
Cucumber provides an annotation called @CucumberOptions, which works like a configuration file for your test suite. When we run tests from an IDE such as Eclipse, we don’t use command-line arguments. So, @CucumberOptions is where we define all the important settings for Cucumber.
Inside this annotation, we can specify the path to our Feature File using the features option and tell Cucumber where to find the Step Definition classes using the glue option. These settings help Cucumber connect the Gherkin steps to the actual Java methods that execute them.
Cucumber Options are very important to know in Cucumber automation. @CuucmberOptions as the setting panel or configuration file for Cuucmber test execution. It tells Cucumber What to run, where to find feature files, where step definitions live, which tags to run, what type of reports to generate, and how to format console output. It replaces what you would normally pass through the Cucumber command line, which is especially useful when running tests from an IDE like Eclipse.
Why @CuucmberOptions is important
@CuucmberOptins helps you organize your project, control which scenarios run, enable readable console output, generate html/json report, and integrate with Jenkins or CI/CD. Avoid long command line arguments. It keeps the TestRunner clean and makes framework flexible
TestRunner class with @CucumberOptions Example:

Explanation of each option
· features
· glue
· tags
· plugin
· dryrun
· monochrome
· format
· strict
features:
In Cucumber, the features option inside the @CucumberOptions annotation tells the framework where to find all the .feature files in your project. Once the flolder path is provided, Cucumber automatically scans the directory and picks up every feature file for execution.
For simple setups, you can point directly to a folder like features = “features”
In large frameworks, this is often modularized by domain.
features = {
"src/test/resources/features/login",
"src/test/resources/features/array",
"src/test/resources/features/stack"
}
This improves scalability and parallel execution.

glue:
In Cucumber, the glue option plays an important role in connecting your Feature Files to the Step Definition code. When Cucumber executes a scenario, it reads each step and then searches for the matching Step Definition inside the folder specified in the glue path.
If your step definitions are stored in a straightforward package, you can simply use
glue = “stepdefinition”

But if your project has a deeper floder structure, you can point Cucumber to the exact location, such as
glue = “src/test/stepdefinition”
By configuring the glue option correctly, you ensure that Cucumber can always locate the right step definitions and execute your scenarios.
This separation supports clean architecture and reduces step duplication.
tags:
Tag expression allows complex filtering. It is great way to organize features and scenarios. Cucumber executes all the scenarios from the feature file by default. If you want to run a specific scenario from the feature file, then a tag is used. It gives flexible execution of scenarios or features based on specific tags. Tags in Cucumber provide a powerful way to organize and selectively execute scenarios. Instead of running the entire suite, tags allow you to filter tests using logical operators such as AND, OR, and NOT. This makes your test suite modular, scalable, and CI‑friendly. Tags can be applied to Features, Scenarios, Scenario Outlines, and Examples, and multiple tags can be combined to create flexible execution strategies.
· @Smoke
· @Regression
· @negativeTC_Login

This is essential for CI pipelines where different jobs run different slices of the suite.
plugin:
plugins turn raw execution into actionable reports.
Common plugins:
· HTML -> readable summary
· JSON -> consumed by Jenkins
· Junit XML -> CI test reporting
· Extent Reports -> dashboards for leadership

This is where your framework becomes presentation ready
dryrun:
Cucumber provides a helpful setting called dryrun that kets us validate our step definitions before running the actual tests. When we turn dryrun = true, Cucumber doesn’t execute any scenarios. Instead, it scans the Feature file and checks whether every step has a corresponding method in the Step Definition class.
If a step is missing, Cucumber immediately reports it and even suggests the method signature we need to add. This makes it easy to complete all step definitions before running the full test suite.
Once all steps are implemented, we switch dryrun = false so the scenarios can run normally.
monochrome:
Cucumber provides a setting called monochrome that improves the readability of the console output. When this option is set to true, Cucumber removes unnecessary characters and formatting, making the logs clean and easy to understand.
Removes unreadable ANSI characters from console logs. Critical when logs are parsed by CI tools.

format:
Cucumber provides a format option that controls how test results are generated and displayed. This is especially useful when integrating with reporting tools or CI/CD pipelines.
The Pretty formatter prints the Gherkin steps in a clean, color-coded format, making it easier to read failures and stack traces during execution.
format = {"pretty"}
The HTML formatter generates a complete HTML report in the folder you specify, giving you a visual summary of all scenarios and steps.
format = {"html:Folder_Name"}
The JSON formatter outputs the entire test execution in JSON format. This is commonly used by tools like Jenkins or third-party plugins to create advanced dashboards and charts.
format = {"json:Folder_Name/cucumber.json"}
Each formatter is added inside the TestRunner using the format = { } option.
publish = true:
Automatically publishes a cloud-hosted Cucumber report.
Useful for distributed teams.
Conclusion
Now you know how powerful @CucumberOptions is in building a clean, scalable, and CI‑friendly automation framework. Mastering these options gives you full control over your test execution, reporting, and project structure.
Thankyou! Happy Learning!!


