Cargo test printing 'println' output from child threads

I have a test which spawn new threads. I'm using the 'println!' macro in these tests and this output always get printed to stdout even when not using cargo test -- --nocapture. Even the -q / --quiet flag don't change anything.

Is that the expected behavior?

This is known behavior. Redirecting stdout is a thread local thing and libtest redirects stdout for the threads it creates to run your tests in. If you spawn a new thread, it does not inherit the redirection, and therefore writes to the original process stdout rather than the redirected stdout.

Ok thanks for the clarification!