gpt4 book ai didi

rust - 如何运行特定模块下的所有测试功能?

转载 作者:行者123 更新时间:2023-12-03 11:46:30 24 4
gpt4 key购买 nike

假设有一个模块,下面有多个测试,比如下面这个。你如何运行这个模块下的所有测试而不是其他模块?

#[cfg(test)]
mod cool_tests {
#[test]
fn first_test() {
// Test Code
}

#[test]
fn second_test() {
// Test Code
}
}

最佳答案

您可以简单地运行模块下的所有测试,如下所示:

cargo test cool_tests::

如果你想根据名字过滤,说出所有以'first'开头的,你可以运行测试如下:

cargo test cool_tests::first

关于rust - 如何运行特定模块下的所有测试功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66414929/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com