Skip to content

Guides · 7 of 7

Migrate to 0.6

Most suites move from 0.5 to 0.6 by bumping three versions. What follows is the list of what can still break, ordered by how many suites it touches.

Bump the versions

rstest-bdd 0.6.0 needs Rust 1.88 or newer, because its Gherkin parser does. Move the runtime and the macros together.

Cargo.toml
[dev-dependencies]
rstest = "0.26.1"
rstest-bdd = "0.6.0"
rstest-bdd-macros = "0.6.0"

Compiled and run against rstest-bdd 0.6.0.

What any suite may hit

An underscore no longer names a different fixture

Exactly one leading underscore is dropped from an implicit fixture name, so _world and world both ask for the world fixture. A parameter underscored only to quiet the unused-variable lint needs no change. One that meant a fixture literally named _world now says so:

From the v0.6.0 migration guide
#[scenario(path = "tests/features/search.feature")]
fn search_works(#[from(_world)] world: SearchWorld) {}

Quoted from the migration guide.

A Result alias can now fail a scenario

A step returning a local alias of Result<T, E> used to have its Err boxed up as a value and ignored, so the scenario passed. It now fails at that step, and Ok(T) injects the T. A scenario that turns red here was wrong before; the error type must implement Display.

The Tokio runtime alias is deprecated

scenarios!(…, runtime = "tokio-current-thread") still compiles, with a warning, as an alias for harness = rstest_bdd_harness_tokio::TokioHarness. Name the harness instead, and add rstest-bdd-harness-tokio as a dev-dependency; the harnesses page shows the form.

Custom harnesses

HarnessAdapter::run now returns HarnessResult<T>, so a harness that fails to build its runtime reports an infrastructure error rather than panicking inside the scenario. Wrap the result in Ok, and map construction errors to HarnessError:

tests/own_stage.rs
impl HarnessAdapter for LanternStage {
    type Context = ();

    fn run<T>(&self, request: StdScenarioRunRequest<'_, T>) -> HarnessResult<T> {
        eprintln!("lighting the lantern stage");
        Ok(request.run_without_context())
    }
}

Compiled and run against rstest-bdd 0.6.0.

A harness named in harness = … is built with Default, so it must implement both traits. Only projects that adopted the harness API from the 0.6.0 development branch have one to change.

Direct API callers

These affect only code that calls the runtime or the language server’s library directly; generated scenario code is updated by the macros.

  • StepContext::insert_value returns InsertOutcome instead of Option<Box<dyn Any>>.
  • record_bypassed_steps takes a BypassedScenario descriptor and the bypassed steps.
  • Feature paths in diagnostics, the JSON report, and JUnit’s classname are relative to the crate’s manifest directory.
  • The language server’s indexing functions return RustStepIndexResult, and find_feature_files returns a Result.

The migration guide has before-and-after code for each, and a list of common errors.