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

Hangs when used with fail-fast option #241

Closed stepantubanov closed 1 year ago

stepantubanov commented 2 years ago

I think there may be a bug with --fail-fast behavior. I'm assuming it should force cucumber to exit on first failure. Instead I'm seeing step failure (as expected) and afterwards it just hangs (doesn't exit, seems to be stuck in an infinite loop somewhere).

# tests/scenarios
use cucumber::{then, World as _};

#[derive(cucumber::World, Debug, Default)]
struct World;

#[then(expr = "step panics")]
async fn step_panics(_: &mut World) {
    panic!("this is a panic message");
}

#[then(expr = "nothing happens")]
async fn nothing_happens(_: &mut World) {
    // noop
}

#[tokio::main]
async fn main() {
    World::cucumber()
        .max_concurrent_scenarios(1)
        .run_and_exit("tests/check.feature")
        .await;
}
# tests/check.feature
Feature: A
  Scenario: 1
    Then step panics

  Scenario: 2
    Then nothing happens

Cargo.toml:

...

[dependencies]
cucumber = "0.15"
tokio = { version = "1", features = ["full"] }

[[test]]
name = "scenarios"
harness = false

And run like this: cargo test --test scenarios -- --fail-fast

tyranron commented 1 year ago

The problem why this hangs is this change which makes is_finished evaluate to true when fail_fast happens, so we never exit the execution loop.

tyranron commented 1 year ago

@stepantubanov released in 0.16.0.