dream_test/gherkin/parser
Parse Gherkin .feature files into gherkin/types.Feature.
Use this when you have Gherkin text (from a file on disk, a fixture, or a
string literal) and you want a structured representation you can convert
into runnable tests via dream_test/gherkin/feature.
The parser supports common Gherkin syntax:
Feature / Scenario / Scenario Outline, Background, tags (@tag), steps,
DocStrings ("""), DataTables (| ... |), Examples tables, and comments.
Values
pub fn parse_file(
path 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.featurefile
Returns
Ok(Feature): Successfully parsed featureError(String): Parse error with description
Example
let assert Ok(feature) = parser.parse_file("test/cart.feature")
pub fn parse_string(
content 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 featureError(String): Parse error with description
Example
let content =
"@smoke\n"
<> "Feature: Demo\n"
<> "\n"
<> " Scenario: One\n"
<> " Given a thing\n"
use feature <- result.try(parser.parse_string(content))
feature.name
|> should
|> be_equal("Demo")
|> or_fail_with("expected feature name Demo")