Skip to content

Commit

Permalink
Merge pull request #55 from alexheretic/master
Browse files Browse the repository at this point in the history
update readme 'in tests' init usage
  • Loading branch information
KodrAus authored Jan 17, 2018
2 parents 1908978 + d82ea19 commit 5a98e48
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ mod tests {

#[test]
fn it_adds_one() {
let _ = env_logger::init();
let _ = env_logger::try_init();
info!("can log from the test too");
assert_eq!(3, add_one(2));
}

#[test]
fn it_handles_negative_numbers() {
let _ = env_logger::init();
let _ = env_logger::try_init();
info!("logging from another test");
assert_eq!(-7, add_one(-8));
}
Expand All @@ -105,7 +105,7 @@ test tests::it_adds_one ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
```

Note that `env_logger::init()` needs to be called in each test in which you
Note that `env_logger::try_init()` needs to be called in each test in which you
want to enable logging. Additionally, the default behavior of tests to
run in parallel means that logging output may be interleaved with test output.
Either run tests in a single thread by specifying `RUST_TEST_THREADS=1` or by
Expand Down

0 comments on commit 5a98e48

Please sign in to comment.