Parsing Scenario Tags

Learn how to parse scenario tags using the Gherkin parser class.

Implementation of Gherkin scenario tags

Gherkin supports adding various tags to scenarios. The code snippet below demonstrates how tags can be added to a scenario to organize them:

Feature: Feature Name

  @tagOne @tagTwo @tagThree
  Scenario: Doc String Example One
    Given a blog post named "Random" with Markdown body

Our strategy to get these lines into a list of Tag objects will be relatively straightforward. The basic process will be to split our input string into an array on the @ symbol. Once we have the list of tags, we can then filter out empty strings and create our Tag instances:

Get hands-on with 1200+ tech skills courses.