Why doesn't println! output text in Rust unit tests?
Hello! I started learning Rust and encountered a strange problem when writing unit tests. I want to output debug information using the `println!` macro, but nothing appears in the terminal. Here's my code:
```rust
#[cfg(test)]
mod tests {
#[test]
fn test_debug_output() {
let value = 42;
println!("Value: {}", value);
assert_eq!(value, 42);
}
}
```
When I run the tests with `cargo test`, I only see:
```
running 1 test
test tests::test_debug_output ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
```
There's no output of `"Value: 42"`. I expected `println!` to work like in normal code. Why is this happening? How can I see debug output during testing? I'm using
No answers yet.
Log in to leave an answer