Maybe strange question, but I want to debug some tests (for myself) with temporary println!
macro, but seems I can operate with assert
only.
Can I use println!
in tests for output or that's wrong idea even for development needs?
Maybe strange question, but I want to debug some tests (for myself) with temporary println!
macro, but seems I can operate with assert
only.
Can I use println!
in tests for output or that's wrong idea even for development needs?
By default, the test harness hides all output from println
and friends unless the test fails. Your options are:
println
s.--show-output
option, to show output even from failing tests.--nocapture
option, to not capture output at all (this means that unless you are running exactly one test, output from multiple threadswill be interleaved).Such test options need to be explicitly passed to the test binary and not Cargo, like this:
cargo test -- --show-output
or
cargo test --test my_integration_test -- --nocapture my_test_function_name
Thank you much!