Visual studio code 是否可以通过Visual Studio代码运行#[tokio::test]标记的单元测试?
是否可以通过Visual Studio代码运行#[tokio::test]标记的单元测试?我看不到这种测试用例的“运行测试”选项。更新:当前版本的VSCode插件支持运行通过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测试_答案(){ 断言
#[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]只是开箱即用。