File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,14 +73,14 @@ mod tests {
7373
7474 #[test]
7575 fn it_adds_one () {
76- let _ = env_logger :: init ();
76+ let _ = env_logger :: try_init ();
7777 info! (" can log from the test too" );
7878 assert_eq! (3 , add_one (2 ));
7979 }
8080
8181 #[test]
8282 fn it_handles_negative_numbers () {
83- let _ = env_logger :: init ();
83+ let _ = env_logger :: try_init ();
8484 info! (" logging from another test" );
8585 assert_eq! (- 7 , add_one (- 8 ));
8686 }
@@ -105,7 +105,7 @@ test tests::it_adds_one ... ok
105105test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
106106```
107107
108- Note that ` env_logger::init () ` needs to be called in each test in which you
108+ Note that ` env_logger::try_init () ` needs to be called in each test in which you
109109want to enable logging. Additionally, the default behavior of tests to
110110run in parallel means that logging output may be interleaved with test output.
111111Either run tests in a single thread by specifying ` RUST_TEST_THREADS=1 ` or by
You can’t perform that action at this time.
0 commit comments