Why doesn't println! output text in Rust unit tests?
Hi everyone! I just started learning Rust and encountered a strange problem. I'm writing a simple unit test for a function that adds two numbers. I want to print the result to the console for debugging, but `println!` inside the test doesn't output anything. Here's my code:
```rust
fn add(a: i32, b: i32) -> i32 {
a + b
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add() {
let result = add(2, 3);
println!("Result: {}", result); // Nothing is printed!
assert_eq!(result, 5);
}
}
```
I run the test with `cargo test` and only see the message "running 1 test" and "test result: ok". No console output at all. I even tried using `println!("Hello")` at the very beginning of the test — still silent.
I expected `println!` to work as