rstest-bdd, when…
- the crate already tests with
rstest, and scenarios should share its fixtures; - scenarios should run under
cargo test, with its filters, parallelism, and IDE support; - each scenario’s state should be isolated by default.
Compare
cucumber-rs ports classic Cucumber to Rust and does it well. rstest-bdd treats BDD as an extension of rstest, for teams already invested in cargo test.
Side by side
Both read Gherkin and run Rust steps. They part ways over who runs the tests and where state lives.
| rstest-bdd | cucumber-rs | |
|---|---|---|
| Test runner | cargo test, with rstest underneath |
Its own, started by World::run(…) |
| State | rstest fixtures, fresh per scenario |
A World struct per scenario |
| Finding steps | Registered at compile time, matched at run time | Collected by the runner |
| Scenario Outlines | One rstest case per Examples row |
Expanded by the runner |
| Async | Tokio current-thread, as an async scenario or through TokioHarness |
Built in, on the runtime the runner is given |
| Missing steps | Fail at run time; a compile error under strict validation | Reported by the runner |
| Philosophy | BDD as an extension of rstest |
A Rust port of classic Cucumber |
Coming from cucumber-rs
A cucumber-rs suite moves across concept by concept. The feature files do not change.
A fixture, or severalEach scenario gets fresh fixtures; a step asks for the ones it needs by name.
&mut World in a step&mut FixtureSteps take &mut to a fixture the scenario owns. No RefCell.
Option fields on the WorldSlot<T>Empty until a step fills it, reset in one call.
Expensive setup shared by all#[once] fixtureBuilt once and kept read-only; per-scenario data is built from it.
#[given(expr = "…")]The same, acceptedThe step macros take expr = for a gentler move.
The runner’s filterscargo test filters and tagsTag expressions choose scenarios at compile time; test names filter at run time.
Choosing
rstest, and scenarios should share its fixtures;cargo test, with its filters, parallelism, and IDE support;World per scenario is the model the team wants;