在 运行 `cargo test` 时记录
logging while running `cargo test`
#[macro_use]
extern crate log;
fn whatever() {
info!("whatever")
}
#[test]
fn test() {
whatever();
}
我想在 运行 单元测试 (cargo test
) 后查看日志,
怎么可能现在?
log
crate 本身不做任何日志记录。来自 the main documentation page:
If no logging implementation is selected, the facade falls back to a "noop" implementation that ignores all log messages.
为了让您的日志消息能够随处可见,您必须初始化特定的日志记录实现,例如 env_logger
. However, it seems that right now, there is no way to perform initialization before tests are run。
#[macro_use]
extern crate log;
fn whatever() {
info!("whatever")
}
#[test]
fn test() {
whatever();
}
我想在 运行 单元测试 (cargo test
) 后查看日志,
怎么可能现在?
log
crate 本身不做任何日志记录。来自 the main documentation page:
If no logging implementation is selected, the facade falls back to a "noop" implementation that ignores all log messages.
为了让您的日志消息能够随处可见,您必须初始化特定的日志记录实现,例如 env_logger
. However, it seems that right now, there is no way to perform initialization before tests are run。