-
In the book it states tests can be executed asynchronously as such: #[tokio::main]
async fn main() {
AnimalWorld::run("tests/features/book/quickstart").await;
} However in my use case, that being a web server which receives a request to execute a cucumber test, I would like to run said test on a separate thread, allowing the handler to exit and once the test has been executed, the result is saved to a database. Naively I went with something like this: tokio::spawn(async {
AnimalWorld::cucumber().fail_fast().run("tests/features/book/quickstart").await;
}); However this does not work because future is not Therefore I was wondering if the cucumber-rs team might have already encountered this particular use case and could kindly point me in the right direction. Thank you :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@niclo I'm not quite sure I understand the use-case here.
Can you elaborate? |
Beta Was this translation helpful? Give feedback.
@niclo in case your tests do not contain significant blocking logic, there is no need to run tests in a separate thread. Just use
.await
. In case there is blocking code, you should wrap it in atokio::spawn_blocking
.Alternatively you can spawn a thread, spin up a new
tokio
runtime and then block onWorld::run()
.