Report the progress of a long running test

Is there any way to report the progress of a long running test? I tried to print the progress in a test function with IO flush but it doesn't work even if I run the test with cargo test -- --show-output. The printed messages doesn't show up until the test function is finished. Is there any way to make stdout of a test function show up immediately?

Or is there a better way to report the progress of a long running test?

Yes, try cargo test -- --nocapture.

1 Like

Thank you so much!

I mistakenly thought --show-output and --nocapture were the same.

Quoted below is from ChatGPT. In short, --show-output captures stdout and display it after a test passes.

"--no-capture" and "--show-output" are command line options for the cargo test command in Rust.

--no-capture specifies that the output of the tests should not be captured and printed to the console. This allows you to see the output of println! statements or other debugging information during testing.

--show-output specifies that the output of passed tests should be displayed, even if it was captured. This is useful when you want to see the output of a test that passed, but it was not displayed because it was captured by default.

In summary, --no-capture shows the output of all tests, while --show-output shows the output only of passed tests.

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.