Everything about Cucumber Options in BDD Framework

Опубликовано: 30 Май 2026
на канале: Viplove QA - SDET
14,705
58

Cucumber Options (@CucumberOptions) in BDD

In Cucumber with Java, the @CucumberOptions annotation is used to configure test execution. It allows you to specify various settings such as feature file locations, glue code, reporting formats, and more.

Common @CucumberOptions Parameters

1. features

Specifies the location of feature files.

Example:

@CucumberOptions(features = "src/test/resources/features")



2. glue

Defines the package where step definitions are located.

Example:

@CucumberOptions(glue = "com.example.stepdefinitions")



3. plugin

Used for reporting. Common plugins include:

pretty: Prints readable output

json: Generates a JSON report

html: Creates an HTML report


Example:

@CucumberOptions(plugin = {"pretty", "html:target/cucumber-reports"})



4. tags

Filters scenarios to run based on tags in feature files.

Example:

@CucumberOptions(tags = "@smoke")



5. dryRun

If true, checks if all step definitions are implemented without executing tests.

Example:

@CucumberOptions(dryRun = true)



6. monochrome

If true, removes unreadable characters from console output.

Example:

@CucumberOptions(monochrome = true)



7. strict (Deprecated in newer versions)

Used to fail the execution if undefined steps exist.




Example @CucumberOptions Usage

@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/resources/features",
glue = "com.example.stepdefinitions",
plugin = {"pretty", "html:target/cucumber-reports", "json:target/cucumber.json"},
tags = "@smoke",
dryRun = false,
monochrome = true
)
public class TestRunner {
}