dream_test/reporter/gherkin
Gherkin-style test reporter for dream_test.
This reporter formats Gherkin test results in a Cucumber-like format that mirrors the Given/When/Then structure of your scenarios.
Example Output
Feature: Shopping Cart
Scenario: Adding items ✓ (2ms)
Scenario: Removing items ✗ (3ms)
✗ equal
Message: Item count mismatch
Expected: 7
Actual: 10
Summary: 2 run, 1 failed, 1 passed in 5ms
Usage
import dream_test/gherkin/feature
import dream_test/runner
import dream_test/reporter/gherkin as gherkin_reporter
import gleam/io
pub fn main() {
my_feature_suite()
|> runner.run_suite()
|> gherkin_reporter.report(io.print)
}
Status Markers
| Status | Marker | Meaning |
|---|---|---|
| Passed | ✓ | All steps succeeded |
| Failed | ✗ | One or more steps failed |
| Skipped | - | Scenario was skipped |
| Pending | ~ | Scenario is a placeholder |
| TimedOut | ! | Scenario exceeded timeout |
| SetupFailed | ⚠ | A setup hook failed |
Values
pub fn format(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
let report_string = format(results)
file.write("cucumber-results.txt", report_string)
pub fn is_gherkin_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
let gherkin_results = list.filter(results, is_gherkin_result)
let unit_results = list.filter(results, fn(r) { !is_gherkin_result(r) })
pub fn report(
results: List(types.TestResult),
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
results |> report(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.