Skip to main content

Crate ferridriver_bdd

Crate ferridriver_bdd 

Source
Expand description

ferridriver-bdd: BDD/Cucumber/Gherkin support for ferridriver.

This crate provides:

  • Gherkin .feature file 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 TestPlan for the core TestRunner
  • 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 TestConfig and CliOverrides.

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.