vscode-rust
vscode-rust copied to clipboard
tokio:test is not recognized as a test
Hey there,
I'm writing a rust program which uses tokio for async functions. I wrote some tests for these async functions and need to annotate them with #[tokio:test] instead of #[test].
Because it's another annotation, the extension doesn't recognize it as a test, so the "Run test" text is missing.
Is it possible to add this annotation? It's pretty handy to run only a singe test with this clickable text
Minimal example
#[tokio:test]
async fn test_example() {
let body = reqwest::get("https://www.rust-lang.org")
.await?
.text()
.await?;
println!("body = {:?}", body);
}
I've got exactly the same problem, only with actix_rt:test instead.
What may be best is to be able to configure which attributes are recognised so that people can add their own as needed.
I switched to rust-analyzer.. It's faster and support other test macros. Mayber you @sazzer can give it a try as well :)
Same problem with tokio 1.20.1 and rust 1.63. I'm using rust-analyzer
Fixed.
Initially I just added tokio to my Cargo file as tokio = "^1.20". The correct way to add the dependency for my tests was tokio = { version = "^1.20", features = ["rt-multi-thread", "macros"] }.
If you are going to use more tokio feature, you can use {..., features = ["full"]} instead.
@ccddan consider filing rust-analyzer issues in its own repo.
If you still have trouble with attribute proc macros, you can use rust-analyzer.procMacro.ignored to ignore them.