TAGS

Tags in Cucumber are used to group scenarios, filter which tests to run, and organize your feature files. They are super helpful when working with large test suites and need to execute a subset of tests.

Tags are annotations in your feature files (preceded by @) that help you:

  • Group scenarios
  • Filter which tests to run
  • Execute based on specific criteria (e.g., smoke, regression)

Run Scenarios with:

A single tag: tags ------------------>>  "@Smoke"
Multiple tags (OR): tags ------------------>>   "@Smoke or @Regression"
Multiple tags (AND): tags ------------------>>   "@Smoke and @Regression"
Negate a tag: tags ------------------>>  "not @WIP"


@CucumberOptions(

features = "src/test/java/features",

glue = "stepDefinitions",

tags = "@Smoke and @Regression",

monochrome = true,

plugin = {"pretty", "html:target/cucumber-reports.html"}

)

public class TestNGRunner extends AbstractTestNGCucumberTests {}



Run only @Smoke scenarios -------- >> tags = "@Smoke"

Run both @Smoke and @Regression (OR) -------- >> tags = "@Smoke or @Regression"

Run only scenarios that are both @Smoke AND @Admin -------- >> tags = "@Smoke and @Admin"

Exclude @WIP (work in progress)-------- >>tags = "not @WIP"