cucumber tags not filtering scenarios: how to fix
Diagnoses why cucumber tags are not filtering scenarios: shell quoting, tag expression syntax, and cucumber version differences. Use when tagged scenarios run that should have been excluded, or nothing runs at all. Not for choosing tag naming conventions.
TL;DR
Tags not filtering almost always comes down to three things: how the shell handles your quotes, which tag-expression syntax your cucumber version expects, and whether the tag is actually on the scenario. Old cucumber used --tags ~@wip; new versions use tag expressions like not @wip. Pass the expression exactly as documented and verify with a dry run.
The query
cucumber tags not filtering scenarios: how to fixUse this when
- Scenarios run even though you excluded their tag.
- Zero scenarios run when you expected a subset.
- You upgraded cucumber and tags stopped filtering.
Not for
- Designing a tag taxonomy for your suite.
- Tag-based reporting; this is about selection only.
Steps
- Check your cucumber version and its tag syntax: ruby cucumber 3+ and cucumber-js 7+ use tag expressions (
not @wip,@smoke and @fast), older versions use--tags ~@wip. Expected output: you know which syntax applies. - Run with single quotes around the expression to stop the shell eating characters:
cucumber --tags 'not @wip'. Expected output: the command runs without shell warnings. - Confirm the tag is spelled identically on the scenario, including case and any hyphens. Expected output: tag names match character for character.
- Run a dry run (
--dry-run) and list which scenarios would execute. Expected output: the dry-run list shows exactly the filtered set. - If using profiles or a config file, check that it is not overriding your
--tagsflag. Expected output: no config is silently replacing your filter.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_hPjGQJoVEPN-lrXGAlLW0w
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.