Testing / Cucumber Interview Questions
Why use tag expressions instead of simple tag matching for selective test execution?
Early Cucumber versions supported only simple, comma/space-separated tag lists with limited combining logic. Modern tag expressions support full boolean logic, and, or, not, and parentheses for grouping, which lets a single run target precisely the intersection of tags actually needed.
# Run smoke tests, but never slow ones, regardless of other tags cucumber.filter.tags=@smoke and not @slow # Run either regression or nightly tests, but exclude anything flaky cucumber.filter.tags=(@regression or @nightly) and not @flaky
Without boolean tag expressions, achieving the same selectivity ("run smoke tests but skip the slow ones") would require either maintaining redundant, overlapping tag combinations on every scenario (like a separate @smokeButNotSlow tag) or running broader queries and manually filtering afterward. Expression-based tag matching lets the same small set of simple, single-purpose tags (@smoke, @regression, @slow, @flaky) be combined flexibly at run time for whatever specific subset a given CI job or local run actually needs.
More Related questions...