Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code 是否可以通过Visual Studio代码运行#[tokio::test]标记的单元测试?_Visual Studio Code_Rust - Fatal编程技术网

Visual studio code 是否可以通过Visual Studio代码运行#[tokio::test]标记的单元测试?

Visual studio code 是否可以通过Visual Studio代码运行#[tokio::test]标记的单元测试?,visual-studio-code,rust,Visual Studio Code,Rust,是否可以通过Visual Studio代码运行#[tokio::test]标记的单元测试?我看不到这种测试用例的“运行测试”选项。更新:当前版本的VSCode插件支持运行通过#[tokio::test]标记的测试,因此不再需要这种解决方法 我有完全相同的问题,通过使用#[tokio::main]和#[test]而不是#[tokio::test]解决了这个问题: async fn answer()->usize{ 42 } #[tokio::main] #[测试] 异步fn测试_答案(){ 断言

是否可以通过Visual Studio代码运行#[tokio::test]标记的单元测试?我看不到这种测试用例的“运行测试”选项。

更新:当前版本的VSCode插件支持运行通过
#[tokio::test]
标记的测试,因此不再需要这种解决方法


我有完全相同的问题,通过使用
#[tokio::main]
#[test]
而不是
#[tokio::test]
解决了这个问题:

async fn answer()->usize{
42
}
#[tokio::main]
#[测试]
异步fn测试_答案(){
断言(答案()等待,42);
}
以这种方式编写异步单元测试时,Visual Studio代码能够运行这些测试:


我无法编译#[tokio::test]测试fn,但这很有效!在我的设置(使用RLS的标准Rust插件)中,我没有看到#[tokio::test]下方的“Run test”按钮,这可能只是Rust analyzer或其他插件中的某个功能吗?切换到
Rust analyzer
插件,甚至不再需要此解决方法<代码>#[tokio::test]只是开箱即用。