Gherkin.Parser (Cucumber v0.3.0)

View Source

Minimal Gherkin 6 parser (Feature, Background, Scenario, Step).

This module parses Gherkin feature files into Elixir structs, supporting:

  • Feature with name, description, and tags
  • Background with steps
  • Scenarios with steps and tags
  • Steps with keywords, text, docstrings, and datatables

It implements a subset of the Gherkin language focused on core BDD concepts.

Summary

Functions

Parses a Gherkin feature file from a string into structured data.

Functions

parse(gherkin_string)

Parses a Gherkin feature file from a string into structured data.

This function takes a string containing Gherkin syntax and parses it into a structured Gherkin.Feature struct with its associated components.

Parameters

  • gherkin_string - A string containing Gherkin syntax

Returns

Returns a %Gherkin.Feature{} struct containing:

  • name - The feature name
  • description - The feature description
  • tags - List of feature-level tags
  • background - Background steps (if present)
  • scenarios - List of scenarios

Examples

# Parse a string containing Gherkin syntax
Gherkin.Parser.parse("Feature: Shopping Cart

Scenario: Adding an item")

# Returns %Gherkin.Feature{} struct with parsed data