dream_test/gherkin/parser

Gherkin parser for .feature files.

Parses Gherkin syntax into structured Feature types that can be converted to dream_test TestSuites.

Supported Syntax

Example Usage

import dream_test/gherkin/parser

// Parse from file
case parser.parse_file("test/features/shopping.feature") {
  Ok(feature) -> run_feature(feature)
  Error(msg) -> panic as msg
}

// Parse from string
let content = "Feature: My Feature\n  Scenario: Test\n    Given something"
case parser.parse_string(content) {
  Ok(feature) -> run_feature(feature)
  Error(msg) -> panic as msg
}

Values

pub fn parse_file(path: String) -> Result(types.Feature, String)

Parse a .feature file from disk.

Reads the file and parses its contents into a Feature.

Parameters

  • path: Path to the .feature file

Returns

  • Ok(Feature): Successfully parsed feature
  • Error(String): Parse error with description
pub fn parse_string(
  content: String,
) -> Result(types.Feature, String)

Parse Gherkin content from a string.

Parses the provided string as Gherkin syntax.

Parameters

  • content: Gherkin content as a string

Returns

  • Ok(Feature): Successfully parsed feature
  • Error(String): Parse error with description
Search Document