Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support async test cases #16

Closed
magurotuna opened this issue Jan 11, 2024 · 0 comments · Fixed by #17
Closed

Support async test cases #16

magurotuna opened this issue Jan 11, 2024 · 0 comments · Fixed by #17
Labels
enhancement New feature or request

Comments

@magurotuna
Copy link
Member

Currently all the tests annotated with flaky_test are converted into #[test]. Would be great to have support for async test cases, probably by converting them into #[tokio::test].

@magurotuna magurotuna added the enhancement New feature or request label Jan 11, 2024
magurotuna added a commit that referenced this issue Jan 12, 2024
This adds support for `async` test cases by delegating to [`tokio::test`].

With this change, `flaky_test` macro can accept all arguments that [`tokio::test`] takes, and can be used together with `times = <int>` to change the max number of retries. So the most complex usage will look like:

```rust
#[flaky_test(times = 5, tokio(flavor = "multi_thread", worker_threads = 2))]
async fn mytest() {
  // ...
}
```

It also has one breaking change. That is, in order to make the macro syntax extensible for future addition, the support for single integer literal like `#[flaky_test(5)]` is dropped in this commit. Users will need to replace this syntax with `#[flaky_test(times = 5)]`.

Closes #16 

[`tokio::test`]: https://docs.rs/tokio/1.35.1/tokio/attr.test.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant