Skip to content

Commit 5a98e48

Browse files
authored
Merge pull request #55 from alexheretic/master
update readme 'in tests' init usage
2 parents 1908978 + d82ea19 commit 5a98e48

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
105105
test 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
109109
want to enable logging. Additionally, the default behavior of tests to
110110
run in parallel means that logging output may be interleaved with test output.
111111
Either run tests in a single thread by specifying `RUST_TEST_THREADS=1` or by

0 commit comments

Comments
 (0)