dream_test/gherkin/discover

Feature discovery and loading for Gherkin tests.

Provides a builder pattern for discovering .feature files and converting them to TestSuites without manual file parsing.

Example

import dream_test/gherkin/discover
import dream_test/gherkin/steps.{new_registry, step}
import dream_test/runner

pub fn main() {
  let steps = new_registry()
  |> step("I have {int} items", have_items)
  |> step("I add {int} items", add_items)

  discover.features("features/*.feature")
  |> discover.with_registry(steps)
  |> discover.to_suite("my_features")
  |> runner.run_suite()
}

Glob Patterns

Uses Erlang’s filelib:wildcard/1 for pattern matching:

Types

Builder for discovering and loading feature files.

Use features() to create, then chain with with_registry() and to_suite() to build a TestSuite.

pub opaque type FeatureDiscovery

Result of loading features, containing both successes and errors.

pub type LoadResult {
  LoadResult(features: List(types.Feature), errors: List(String))
}

Constructors

  • LoadResult(features: List(types.Feature), errors: List(String))

    Arguments

    features

    Successfully parsed features

    errors

    Errors encountered during parsing

Values

pub fn features(pattern: String) -> FeatureDiscovery

Start discovering features matching a glob pattern.

Parameters

  • pattern: Glob pattern for .feature files

Example

discover.features("features/**/*.feature")
|> discover.with_registry(steps)
|> discover.to_suite("my_tests")
pub fn list_files(discovery: FeatureDiscovery) -> List(String)

Get the list of files matching the discovery pattern.

Useful for debugging or custom file handling.

pub fn load(discovery: FeatureDiscovery) -> LoadResult

Load features and return detailed results.

Use this when you need access to parse errors for custom handling.

Parameters

  • discovery: The feature discovery builder

Returns

LoadResult with lists of successfully parsed features and errors.

pub fn to_suite(
  discovery: FeatureDiscovery,
  suite_name: String,
) -> types.TestSuite

Build a TestSuite from discovered features.

Discovers all matching files, parses them, and creates a combined TestSuite. Parse errors are collected but don’t prevent other features from running.

Parameters

  • discovery: The configured feature discovery
  • suite_name: Name for the combined test suite

Returns

A TestSuite containing all successfully parsed features. If there are parse errors, they’re reported as failed tests.

Panics

Panics if with_registry() was not called.

pub fn with_registry(
  discovery: FeatureDiscovery,
  registry: steps.StepRegistry,
) -> FeatureDiscovery

Attach a step registry to the discovery.

The registry contains all step definitions needed to execute the features.

Parameters

  • discovery: The feature discovery builder
  • registry: Step registry with step definitions
Search Document