dream_test/reporters/gherkin
Gherkin-style report formatting.
This module formats TestResult values with kind GherkinScenario(_ ) in a
Cucumber-like layout (Feature → Scenario), so you can print or persist a
human-readable report for BDD runs.
Most users won’t call this module directly—dream_test/reporters wires it
in automatically—but it’s useful when you want:
- a Gherkin report as a
String(format) - to write the report using a custom function (
report)
Values
pub fn format(results results: List(types.TestResult)) -> String
Format test results as a Gherkin-style report string.
Returns the complete report including:
- Feature name as header
- Scenario names with status markers
- Summary with scenario counts
Use this when you need the report as a string.
Example
gherkin_reporter.format(sample_results())
|> should
|> match_snapshot("./test/snapshots/gherkin_format_report.snap")
|> or_fail_with("expected formatted report snapshot match")
Parameters
results: The test results to format
Returns
The formatted report as a String.
pub fn is_gherkin_result(result result: types.TestResult) -> Bool
Check if a TestResult is from a Gherkin test.
Useful for filtering or routing results to the appropriate reporter.
Example
gherkin_reporter.is_gherkin_result(gherkin_result())
|> should
|> be_equal(True)
|> or_fail_with("expected True for gherkin results")
Parameters
result: A singleTestResultto inspect
Returns
True when result.kind is GherkinScenario(_), otherwise False.
pub fn report(
results results: List(types.TestResult),
write write: fn(String) -> Nil,
) -> List(types.TestResult)
Print test results using a provided writer function.
This is the main entry point for Gherkin test runs.
Example
let results = runner.new([tests()]) |> runner.run()
gherkin_reporter.report(results, io.print)
Parameters
results: List of test results from the runnerwrite: Function that handles the formatted output string
Returns
Returns the input results unchanged, enabling pipeline composition.