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
563 stars 69 forks source link

Book example not working #305

Closed bq-wrongway closed 11 months ago

bq-wrongway commented 11 months ago

I was checking out this example https://cucumber-rs.github.io/cucumber/current/writing/scenario_outline.html

And it does not compile (well, unless i remove .await) keywords.

error[E0277]: `()` is not a future
  --> tests/example.rs:23:35
   |
23 |     sleep(Duration::from_secs(2)).await;
   |     ------------------------------^^^^^
   |     |                            ||
   |     |                            |`()` is not a future
   |     |                            help: remove the `.await`
   |     this call returns `()`
   |
   = help: the trait `futures::Future` is not implemented for `()`
   = note: () must be a future or must implement `IntoFuture` to be awaited
   = note: required for `()` to implement `std::future::IntoFuture`

Am i doing something wrong or the example is missing something ?

ilslv commented 11 months ago

you are probably using std::thread::sleep() instead of the tokio::time::sleep()

tyranron commented 11 months ago

@bq-wrongway we're sure that all the Book examples work, because we check that on CI.

What confuses you, is that the boilerplate code of examples is mostly hidden (the lines started witn #), to not overbloat them with redundant information. This is a widely used feature of rustdoc, and so, mdBook too.

To see the hidden code of an example, you may use this button in mdBook interface:

Screenshot 2023-10-10 at 17 27 19

And they will be shown like this:

Screenshot 2023-10-10 at 17 28 23