cucumber-rs / cucumber

Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.
https://cucumber-rs.github.io/cucumber/main
Apache License 2.0
579 stars 70 forks source link

Sharing state across scenarios #348

Open guenhter opened 2 weeks ago

guenhter commented 2 weeks ago

Hi,

I have a lot of scenarios which are working with a docker testcontainer. Each scenario starts up the container and when the world is dropped, the container is also stopping. When a new world is created, a new container is created. This works fine, but it is slow. I'd appreciate if the container could be started like this:

fn main() {
    let container = startContainer();
    MyWorld::cucumber()
            .fail_on_skipped()
            .add_state(container) // don't nail me on this. Just here to see what I mean
            .run_and_exit("tests/features/user/")
            .await;
    // Container gets stopped when main is exited.
}

When the world is then created, I'd need some way to access the container (e.g. for getting out the correct ports).

What do you think about this?