【问题标题】:logging while running `cargo test` [duplicate]运行`cargo test`时记录[重复]
【发布时间】:2016-05-19 06:55:09
【问题描述】:
#[macro_use]
extern crate log;

fn whatever() {
    info!("whatever")
}

#[test]
fn test() {
    whatever();
}

我想在运行单元测试后查看日志(cargo test), 怎么可能现在

【问题讨论】:

    标签: unit-testing testing logging rust rust-cargo


    【解决方案1】:

    log crate 自身不进行任何日志记录。来自the main documentation page

    如果没有选择日志实现,外观会退回到忽略所有日志消息的“noop”实现。

    为了让您的日志消息可以发送到任何地方,您必须初始化一个特定的日志实现,例如env_logger。不过,现在看来,there is no way to perform initialization before tests are run

    【讨论】:

    • 没有解决办法吗? D:
    猜你喜欢
    • 2019-02-28
    • 2018-08-17
    • 2021-06-19
    • 1970-01-01
    • 2019-08-09
    • 1970-01-01
    • 2015-10-20
    • 2018-03-24
    • 2021-05-20
    相关资源
    最近更新 更多