【问题标题】:Where can I find rust test binary for my project?我在哪里可以找到我的项目的 rust 测试二进制文件?
【发布时间】:2020-05-30 05:16:18
【问题描述】:

我在测试特定文件的特定功能时遇到问题:

mod test {
//...

 #[test]
    #[cfg(feature = "proto-igmp")]
    fn test_handle_igmp() {

我在这里找到https://github.com/rust-lang/cargo/issues/1407,我可以通过将其名称作为参数传递给测试二进制文件来测试特定测试。但是这样的二进制文件在哪里?我可以让println 在测试中工作吗?

我想运行test_handle_igmp 打印一些东西,看看为什么会发生错误。

【问题讨论】:

    标签: rust


    【解决方案1】:

    您可以在target/$MODE/$NAME-$hash 中找到它,例如target/debug/example-3beac917983bc7e3.exe。请注意,可能有多个,一些用于文档测试,一些用于#[test] 函数。

    也就是说,如果你只想运行test_handle_igmp,你可以使用

    cargo test test_handle_igmp -- --nocapture
    

    运行您的测试并查看println 输出。请参阅cargo test --helpthe online documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-13
      • 1970-01-01
      • 1970-01-01
      • 2013-12-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多