Tags & Filtering

Tags are used in CukeTest to classify and filter test resources. Through tags, you can achieve hierarchical management and on-demand execution of test cases.

What are Tags?

Tags are identifiers used in Gherkin syntax to mark test elements. Tags start with the @ symbol, followed by a string that does not contain spaces (e.g., @smoke, @regression, @math, @windows, etc.).

Tags can be applied to various feature elements, including Features, Scenarios, Scenario Outlines, and Example tables (Examples).

A typical example of tag application is as follows:

@math 
### ↑ Define classification tag at the Feature level

Feature: Addition
  In order to avoid calculation errors...

  @sanity
  ### ↑ Define smoke test tag at a specific Scenario
  Scenario: Add two numbers
    Given I have entered 6 into the calculator
    Then I should see 13 as the result on the screen

  @uat
  ### ↑ Define acceptance test tag at the Scenario Outline level
  Scenario Outline: Add three numbers
    Given I have entered <data1> into the calculator
    Examples: 
      | data1 | result |
      | 12    | 17     |
    @complete
    ### ↑ Define data characteristic tag at a specific Example table level
    Examples: 
      | data1 | result |
      | 242   | 376    |

Note

Tag Inheritance: Tags on top-level elements (such as a Feature) are automatically inherited by the child elements they contain (such as Scenarios and Scenario Outlines). For example, if a Feature is marked with @math, all scenarios within it logically carry the @math tag. This facilitates coarse-grained management.

How to Add Tags

In Visual Mode:

  1. Double-click the tag bar above the target element and enter the tag content directly.
  2. CukeTest will automatically add the @ prefix. If you need to enter multiple tags, use spaces to separate them.

Ways to Use Tags

With tags, you can perform two core operations: View Filtering (to look) and Execution Filtering (to run).

1. View Filtering: Filtering Feature Content

When a feature file contains many scenarios, you can quickly filter for specific ones using tags:

  1. Ensure you are in "Visual" mode.
  2. Click the main menu View -> "Filter with Tags…", to open the floating search box.

Enter the tag name in the box and press Enter. The feature view will display only the scenarios matching that tag.

In addition to manual entry, you can also select existing historical tags through the drop-down arrow on the right side of the box.

Tip

Tip: In the filtered results interface, you can click the run button to execute only the scenarios currently filtered.

2. Execution Filtering: Tag Filtering in Run Configuration

When executing tests, you can choose a subset to run based on tags. For example, only run @uat scenarios or exclude ones for a certain environment.

In the Run Configuration interface, set the filtering conditions in the "Tag Filter" field.

You can write complex Boolean logic expressions (supporting and, or, not, and parentheses):

  • @math and @sanity Runs only scenarios that contain both @math and @sanity tags (like "Add two numbers" above).
  • @sanity or @uat Runs all scenarios that contain either tag.
  • @complete Precise control. For example, in the sample above, this runs only the data from the Example table marked with @complete.

For detailed syntax on tag combination logic, please refer to Tag Expressions.

results matching ""

    No results matching ""