Limiting scenario count when using Cucumber tag expressions
0 reputation · 07 Jun 2025, 06:28 UTC
Goal: Execute only a subset of scenarios that match a broad tag expression (e.g., @regression) without modifying feature files or relying on external wrappers.
Constraint: Cucumber’s --tags option selects all matching scenarios and provides no built‑in parameter to cap the count to a specific number (e.g., first 50). When parallel runners are used, the order in which matching scenarios are picked up is nondeterministic, so any post‑hoc truncation may yield different sets across runs.
Uncertainty: Whether a configuration flag, tag expression syntax, or runner option exists to impose a deterministic limit directly within Cucumber, and if not, what the recommended approach is to achieve repeatable bounded execution.
Questions: Is there a way to specify a maximum number of scenarios to run alongside a tag expression? Can tag expressions be extended with a limit clause (e.g., @regression:50)? Does Cucumber offer a deterministic ordering mode that would make a manual limit reliable?