> For the complete documentation index, see [llms.txt](https://lin-4.gitbook.io/test/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lin-4.gitbook.io/test/cucumbertags.md).

# cucumber/tags

<https://github.com/cucumber/cucumber/wiki/Tags>

## Tags

Tags are a great way to organise your features and scenarios. Consider this example:

```
@billing
Feature: Verify billing

  @important
  Scenario: Missing product description

  Scenario: Several products
```

A Scenario or feature can have as many tags as you like. Just separate them with spaces:

```
@billing @bicker @annoy
Feature: Verify billing
```

### Tag Inheritance

Any tag that exists on a Feature will be inherited by Scenario, Scenario Outline or Examples.

### Running a subset of Scenarios

You can use the

`--tags`

option to tell Cucumber that you only want to run features or scenarios that have (or don’t have) certain tags. Examples:

```
cucumber --tags @billing            # Runs both scenarios
cucumber --tags @important          # Runs the first scenario
cucumber --tags ~@important         # Runs the second scenario (Scenarios without @important)

cucumber --tags @billing --tags @important    # Runs the first scenario (Scenarios with @important AND @billing)
cucumber --tags @billing,@important           # Runs both scenarios (Scenarios with @important OR @billing)
```

(Another way to “filter” what you want to run is to use the`file.feature:line`pattern or the`--scenario`option as described in[Running Features](https://github.com/cucumber/cucumber/wiki/Running-Features)).

Tags are also a great way to “link” your Cucumber features to other documents. For example, if you have to deal with old school requirements in a different system (Word, Excel, a wiki) you can refer to numbers:

```
@BJ-x98.77 @BJ-z12.33
Feature: Convert transaction
```

Another creative way to use tags is to keep track of where in the development process a certain feature is:

```
@qa_ready
Feature: Index projects
```

Tags are also used in Tagged [Hooks](https://github.com/cucumber/cucumber/wiki/Hooks), which let you use tags to define what `Before`and `After`blocks get run for what scenarios.

### Logically ANDing and ORing Tags

As you may have seen in the previous examples Cucumber allows you to use logical ANDs and ORs to help gain greater control of what features to run.

Tags which are comma separated are ORed:

Example: Running scenarios which match @important OR @billing

```
cucumber --tags @billing,@important
```

Tags which are passed in separate --tags are ANDed

Example: Running scenarios which match @important AND @biling

```
cucumber --tags @billing --tags @important
```

You can combine these two methods to create powerful selection criteria:

Example: Running scenarios which match: (@billing OR @WIP)AND\@important

```
cucumber --tags @billing,@wip --tags @important
```

Example: Skipping both @todo and @wip tags

```
cucumber --tags ~@todo --tags ~@wip
```

You can use this tag logic in your[Hooks](https://github.com/cucumber/cucumber/wiki/Hooks)as well.

*This feature was originally added in version 0.4.3. The logical behaviour of tags was later reversed in version 0.6.0.*

### Overriding the tag filters from a profile

It is currently not possible to override the tag filters from a profile.

The default profile, for example, includes a`--tags ~@wip`filter. But what if you want to use everything from the default profileexceptthe`--tags ~@wip`portion?

You might think you could just append something like this to the command line to “undo” the`--tags`from the profile:`--tags @wip,~@wip`(anything either **tagged** with @wip or **not** tagged with @wip)

But because that is effectively doing an “and” between`--tags ~@wip`and`--tags @wip,~@wip`, it doesn’t match any scenarios.

How can we override the tag filter then?

### Tag limits and WIP

If you’re following Kanban principles, you want to limit the work in progress (WIP). The idea is that the fewer features or scenarios that being worked on simultaneously, the quicker you’ll be able to implement new features.

Cucumber can enforce this using tag limits. Here is an example:

```
cucumber --tags @dev:2, @qa:3
```

This will make cucumber fail if you have more than 2`@dev`tags or more than 3`@qa`tags, even if each of your scenarios pass individually.

Used in conjunction with the`--wip`switch you can set up your project to enforce theWIPlimits of your team.

### Special Tags

**@allow-rescue**: Turns off Cucumber’s exception capturing for the tagged scenario(s). Used when the code being tested is expected to raise and handle exceptions.

**@javascript**: Uses a javascript-aware system to process web requests (e.g., Selenium) instead of the default (non-javascript-aware) webrat browser.

**@no-txn**: Turns off transactions. See[Browsers and Transactions](https://github.com/cucumber/cucumber/wiki/Browsers-and-Transactions).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://lin-4.gitbook.io/test/cucumbertags.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
