Why doesn't println! work in Rust unit tests?
@lebyy▲ 0 net votes
Problem: I've implemented the following method and unit test: use std::fs::File; use std::path::Path; use std::io::prelude::*; fn read_file(path: &Path) { let mut file = File::op I run the unit test this way: rustc --test app.rs; ./app I could also run this with… Fix (from the top answer): This happens because Rust test programs hide the stdout of successful tests in order for the test output to be tidy. You can disable this behavior by passing the --nocapture option to the test binary or to cargo test (but, in this case after -- – see below): #[test] fn test() { println!("Hidden output") } Invoking…