Share State Between Cucumber Steps Without Static Fields
Use Cucumber JVM dependency injection to share objects across step definitions within a scenario while keeping scenarios isolated.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Use Cucumber JVM dependency injection to share objects across step definitions within a scenario while keeping scenarios isolated.
In Cucumber 7.x and later, the transition from Regular Expressions to Cucumber Expressions has standardized how step parameters are parsed. While types like { int} and { string} improve readability, a specific behavioral challenge arises when multiple step definitions match the same Gherkin line. When a Gherkin step satisfies the criteria for two or more Cuc
Goal We want to know how Cucumber 7.x resolves step definitions when a Gherkin line can be matched by both a Cucumber Expression and a Regular Expression. Context In a mixed‑annotation project, a step may be annotated with both @Given("I have a {int}") and @Given("^I have a (\\d+)$") and can trigger an AmbiguousStepDefinitionException. The current documentat
In multi-module JVM projects using Cucumber JVM 7.x, step definition methods must be public for the glue backend to discover them, whether they use Cucumber Expressions or regular expressions. Package-private or private step methods are ignored during discovery, and the affected steps surface as undefined at runtime rather than as compile-time errors. The de
Cucumber-JVM maps Gherkin steps to Java methods using Cucumber Expressions or regular expressions. When a single step matches multiple definitions, the framework triggers an AmbiguousStepDefinitionsException to prevent non-deterministic execution. Currently, the framework lacks a native priority or weighting mechanism to designate a primary match when overla