Is it possible to log and print test method outputs?

Hello,

I am writing a small program and my test classes should produce error or success output and debug output. I use cargo test -- --nocapture but it prints output from println!()in between the output from cargo.
Is there another way to only see this generated output from the tests?

Captured content is printed when tests fail. If the outputs are important, consider writing them to a file.

1 Like

I'm not sure whether this is what you meant, but to get less intermixed output, use --show-output instead of --nocapture. This captures output like the normal mode, but prints it even if the tests pass.

4 Likes

thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.