Crates.io | testing_logger |
lib.rs | testing_logger |
version | 0.1.1 |
source | src |
created_at | 2018-08-07 00:46:17.279144 |
updated_at | 2018-08-07 02:29:04.571777 |
description | Supports writing tests to verify `log` crate calls |
homepage | |
repository | https://github.com/brucechapman/rust_testing_logger |
max_upload_size | |
id | 77836 |
size | 8,459 |
A Rust library to support testing of code that uses log
crate.
#[macro_use]
extern crate log;
use log::Level;
extern crate testing_logger;
#[test]
fn test_something() {
testing_logger::setup();
warn!("Something went wrong with {}", 10);
testing_logger::validate( |captured_logs| {
assert_eq!(captured_logs.len(), 1);
assert_eq!(captured_logs[0].body, "Something went wrong with 10");
assert_eq!(captured_logs[0].level, Level::Warn);
});
}