cucumber/tag-expressions

Cucumber tag expression parser

Python

21

2,167 commits

updated Oct 13, 2026

See the code

README

test-go test-java test-javascript test-perl test-python test-ruby

Tag Expressions

Tag Expressions is a simple query language for tags. The simplest tag expression is simply a single tag, for example:

@smoke

A slightly more elaborate expression may combine tags, for example:

@smoke and not @ui

Tag Expressions are used for two purposes:

  1. Run a subset of scenarios (using the --tags expression option of the command line)
  2. Specify that a hook should only run for a subset of scenarios (using conditional hooks)

Tag Expressions are boolean expressions of tags with the logical operators and, or and not.

For more complex Tag Expressions you can use parenthesis for clarity, or to change operator precedence:

(@smoke or @ui) and (not @slow)

Escaping

If you need to use one of the reserved characters (, ), \ or (whitespace) in a tag, you can escape it with a \. Examples:

Gherkin TagEscaped Tag Expression
@x(y)@x\(y\)
@x\y@x\\y

Migrating from old style tags

Older versions of Cucumber used a different syntax for tags. The list below provides some examples illustrating how to migrate to tag expressions.

Old style command lineCucumber Expressions style command line
--tags @dev--tags @dev
--tags ~@dev--tags "not @dev"
--tags @foo,@bar--tags "@foo or @bar"
--tags @foo --tags @bar--tags "@foo and bar"
--tags ~@foo --tags @bar,@zap--tags "not @foo and (@bar or @zap)"
go
java
javascript
perl
polyglot-release
python
ruby
tidelift

cucumber/tag-expressions

Cucumber tag expression parser

Python

21

2,167 commits

updated Oct 13, 2026

See the code

README

test-go test-java test-javascript test-perl test-python test-ruby

Tag Expressions

Tag Expressions is a simple query language for tags. The simplest tag expression is simply a single tag, for example:

@smoke

A slightly more elaborate expression may combine tags, for example:

@smoke and not @ui

Tag Expressions are used for two purposes:

  1. Run a subset of scenarios (using the --tags expression option of the command line)
  2. Specify that a hook should only run for a subset of scenarios (using conditional hooks)

Tag Expressions are boolean expressions of tags with the logical operators and, or and not.

For more complex Tag Expressions you can use parenthesis for clarity, or to change operator precedence:

(@smoke or @ui) and (not @slow)

Escaping

If you need to use one of the reserved characters (, ), \ or (whitespace) in a tag, you can escape it with a \. Examples:

Gherkin TagEscaped Tag Expression
@x(y)@x\(y\)
@x\y@x\\y

Migrating from old style tags

Older versions of Cucumber used a different syntax for tags. The list below provides some examples illustrating how to migrate to tag expressions.

Old style command lineCucumber Expressions style command line
--tags @dev--tags @dev
--tags ~@dev--tags "not @dev"
--tags @foo,@bar--tags "@foo or @bar"
--tags @foo --tags @bar--tags "@foo and bar"
--tags ~@foo --tags @bar,@zap--tags "not @foo and (@bar or @zap)"
go
java
javascript
perl
polyglot-release
python
ruby
tidelift

Project health

Overall

7.3/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

Latest release

11.0.1 · Aug 5, 2026

Releases this year

7

Significant stargazers

Max Schmitt

2,116 followers · starred Jan 2024

Victor Duarte

233 followers · starred Jul 2026