是否可以通过 Visual Studio 代码运行 #[tokio::test] 标记的单元测试?我没有看到此类测试用例的“运行测试”选项。
最佳答案
更新 : 当前版本的 VSCode 插件支持通过 #[tokio::test]
标记的运行测试所以这个解决方法不再是必要的。
我有完全相同的问题并通过使用 #[tokio::main]
解决了它和 #[test]
而不是 #[tokio::test]
:
async fn answer() -> usize {
42
}
#[tokio::main]
#[test]
async fn test_answer() {
assert_eq!(answer().await, 42);
}
以这种方式编写异步单元测试时,Visual Studio Code 能够运行这些测试:关于visual-studio-code - 是否可以通过 Visual Studio 代码运行 #[tokio::test] 标记的单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60482983/