• Home
  • Raw
  • Download

Lines Matching +full:test +full:- +full:crates

3 [![crates.io](https://img.shields.io/crates/v/env_logger.svg)](https://crates.io/crates/env_logger)
41 [2018-11-03T06:09:06Z INFO default] starting up
51 [2018-11-03T06:09:06Z INFO default] starting up
59 The log levels that may be specified correspond to the [`log::Level`][level-enum]
68 [level-enum]: https://docs.rs/log/latest/log/enum.Level.html "log::Level (docs.rs)"
74 … besides an environment variable. See [the examples](https://github.com/rust-cli/env_logger/tree/m…
78 Tests can use the `env_logger` crate to see log messages generated during that test:
84 [dev-dependencies]
89 fn add_one(num: i32) -> i32 {
94 #[cfg(test)]
103 #[test]
107 info!("can log from the test too");
111 #[test]
115 info!("logging from another test");
116 assert_eq!(-7, add_one(-8));
121 Assuming the module under test is called `my_lib`, running the tests with the
125 $ RUST_LOG=my_lib=info cargo test
126 Running target/debug/my_lib-...
129 [INFO my_lib::tests] logging from another test
130 [INFO my_lib] add_one called with -8
131 test tests::it_handles_negative_numbers ... ok
132 [INFO my_lib::tests] can log from the test too
134 test tests::it_adds_one ... ok
136 test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
139 Note that `env_logger::try_init()` needs to be called in each test in which you
141 run in parallel means that logging output may be interleaved with test output.
143 running one test by specifying its name as an argument to the test binaries as
144 directed by the `cargo test` help docs:
147 $ RUST_LOG=my_lib=info cargo test it_adds_one
148 Running target/debug/my_lib-...
150 running 1 test
151 [INFO my_lib::tests] can log from the test too
153 test tests::it_adds_one ... ok
155 test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
175 The default format won't optimise for long-term stability, and explicitly makes no guarantees about…