Excluding Tests
The inverse of tag selection is exclusion: you usually want everything except a known problem group. Behave supports exclusion at three levels: by tag, by scenario name, and by commenting a scenario out of the feature file. Picking the right level keeps the exclusion visible and easy to remove later.
Excluding by Tag
Tag the noisy group once, then negate the tag on the command line. This is the cleanest form, because the group is named in the feature file itself:
behave --tags="not @flaky"
behave --tags="not (@slow or @wip)"
Combine negation with positive selection when you want "smoke tests, but not the flaky ones":
behave --tags="@smoke and not @flaky"
Excluding by Scenario Name
The -e / --exclude option takes a regular expression and skips every scenario whose name matches. It is useful for one-off exclusions without touching the feature file:
# skip every scenario whose name mentions the legacy export
behave -e "legacy export" features/
# the opposite: run only scenarios whose name matches
behave -i "login" features/
The -n / --name option works the same way but matches the exact scenario name rather than a regular expression.
Commenting Scenarios Out
A line starting with # is a Gherkin comment. Commenting a Scenario: line disables that scenario (and its steps) until you remove the marker. Use this for scenarios that are permanently out of scope, and prefer tags for temporary exclusions.
Choosing a Level
Use tags when the exclusion is a group property (environment, stability, product area). Use name exclusion for a quick fix during a demo or a release branch. Use comments when the scenario is retired. In all three cases, leave a short note nearby so nobody forgets why the test is hidden.
Summary
Exclude tests with negated tag expressions, the -e name regex, or Gherkin comments. Prefer tags for reusable groups, and always document the reason for the exclusion.