Expand description
ferridriver-bdd: BDD/Cucumber/Gherkin support for ferridriver.
This crate provides:
- Gherkin
.featurefile parsing and scenario expansion - Cucumber expression step matching
- Step registry with proc macro registration (
#[given],#[when],#[then]) - Hook system with tag filtering
- Translation of Gherkin features into
TestPlanfor the coreTestRunner - 109 built-in step definitions covering navigation, interaction, assertions, etc.
- BDD-specific reporters (Gherkin terminal, Cucumber JSON, JUnit, JSON)
§Quick Start
Create a binary crate with custom steps and call bdd_main!():
ⓘ
use ferridriver_bdd::prelude::*;
// Custom step definitions -- auto-registered via inventory
#[given("I am logged in as {string}")]
async fn login(world: &mut BrowserWorld, username: String) {
world.page().goto("https://app.example.com/login", None).await.map_err(|e| step_err!("{e}"))?;
world.page().locator("#email", None).fill(&username, None).await.map_err(|e| step_err!("{e}"))?;
world.page().locator("#password", None).fill("secret", None).await.map_err(|e| step_err!("{e}"))?;
world.page().locator("button[type=submit]", None).click(None).await.map_err(|e| step_err!("{e}"))?;
}
#[then("I should see the dashboard")]
async fn see_dashboard(world: &mut BrowserWorld) {
let loc = world.page().locator("[data-testid=dashboard]", None);
ferridriver_test::expect::expect(&loc).to_be_visible().await.map_err(|e| step_err!("{e}"))?;
}
// Entry point -- discovers .feature files, collects all steps, runs via TestRunner
ferridriver_bdd::bdd_main!();Then run: cargo run -- features/**/*.feature --tags "@smoke"
Re-exports§
pub use inventory;
Modules§
- data_
table - DataTable: a structured Gherkin data table with utility methods.
- executor
- Single BDD execution engine for all consumers (TestRunner, MCP, standalone).
- expression
- Cucumber expression compiler: converts cucumber expressions to regex with typed parameters.
- feature
- Feature file discovery and Gherkin parsing.
- filter
- Tag expression parser and evaluator, grep filtering.
- hook
- Hook system: lifecycle hooks with tag filtering and ordering.
- js
- JavaScript step definitions driven by the shared QuickJS engine.
- param_
type - Custom parameter type registry for extending Cucumber expressions.
- prelude
- Prelude: commonly used types for step definition files.
- registry
- Step registry: collects step definitions from inventory + runtime registration.
- scenario
- Scenario execution model: expansion, variable interpolation, results.
- snippet
- Generate step definition skeletons for undefined Gherkin steps.
- step
- Step definition types:
StepDef,StepParam,StepHandler,StepMatch. - steps
- Built-in step definitions for browser automation.
- translate
- Translation layer: converts Gherkin features into ferridriver-test
TestPlan. - world
- BrowserWorld: shared scenario state with fixtures, variables, and typed extensions.
Macros§
- bdd_
main - BDD test harness entry point.
- step_
err - Convenience macro for creating step errors.
- submit_
hook - Convenience macro for submitting hook registrations from proc macro expansion.
- submit_
step - Convenience macro for submitting step registrations from proc macro expansion.
Functions§
- run_
bdd_ harness - Entry point called by
bdd_main!(). - run_
bdd_ with - Run BDD scenarios against a pre-resolved
TestConfigandCliOverrides.
Attribute Macros§
- after
- Register an After hook.
- before
- Register a Before hook.
- given
- Register a Given step definition.
- param_
type - Register a custom parameter type for Cucumber expressions.
- step
- Register a keyword-agnostic step definition (matches Given/When/Then).
- then
- Register a Then step definition.
- when
- Register a When step definition.