4 releases
0.1.3 | Aug 20, 2023 |
---|---|
0.1.2 | Aug 20, 2023 |
0.1.1 | Jul 10, 2023 |
0.1.0 | Jul 10, 2023 |
#317 in Testing
1,078 downloads per month
6KB
110 lines
Mock Logger for Rust
This is a testing utility providing a mock logging implementation that can be used to verify correctness in your own logging.
Usage
use log::info;
fn log_something() {
info!("something");
}
#[cfg(test)]
mod test {
use mock_logger::MockLogger;
use super::*;
#[test]
fn test_logging() {
mock_logger::init();
log_something();
MockLogger.entries(|entries| {
assert_eq!(entries.len(), 1);
assert_eq!(entries[0].level, log::Level::Info);
assert_eq!(entries[0].body, "something");
});
}
}
Dependencies
~87KB