rust 如何展开“tests”文件夹中的宏

ujv3wf0j  于 2023-02-12  发布在  其他
关注(0)|答案(1)|浏览(175)

如何使用cargo expand来扩展机箱中tests文件夹下测试文件上的宏?

crate
    - src
        - lib.rs
    - tests
        - my_test.rs
    Cargo.toml

cargo expand --lib --tests无法识别它们(?)。--bin也无法识别它们。
my_test.rs中:

#[test]
fn test_it() {
    assert!(true);
}

cargo expand --test test_it使用error: no test target named test_it进行回复
我是否必须添加一些东西到Cargo.toml,以便包括它们?

xytpbqjk

xytpbqjk1#

我能够使用以下命令扩展测试中的宏:
cargo expand --test tests,可能尝试cargo expand --test my_test
该项目与您的项目类似:

crate
    - src
        - lib.rs
    - tests
        - tests.rs
    Cargo.toml

货运版本:1.69.0-nightly

相关问题