Skip to content

Setting a global timeout on all steps #289

Answered by tyranron
ecaponi3 asked this question in Q&A
Discussion options

You must be logged in to vote

@ecaponi3 hi! There is no such built-in functionality in cucumber crate. And I'm quite unsure, that cucumber crate is the correct place for it.

There are multiple ways of resolving this issue:

  1. You can use tokio::time::timeout (or similar), and wrap your step definitions into it:

    #[then("whatever")]
    async fn step(w: &mut World) {
        timeout(Duration::from_secs(30), async move {
            // your logic here...
        })
        .await
        .unwrap_or_else(|e| panic!("step timed out: {e}"))
    }

    With implementing a simple proc macro atop, it may be reduced to:

    #[then("whatever")]
    #[timeout(30)]
    async fn step(w: &mut World) {
        // your logic here...
    }
  2. You can implement your own Runner which have th…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ecaponi3
Comment options

Answer selected by tyranron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants