0

If I create the function

#[test]
fn foo () {
  dbg!("BAR");
  println!("BAZ");
  assert!(true);
}

And I run cargo test -v or cargo test --verbose I can confirm the test ran, but no output is shown. The words "BAR" and "BAZ" do not exist in the output.

When I read cargo test --help, I see different options than in cargo --help: it documents a -vv option. But I don't see a difference with cargo --verbose test -vv, nor cargo test -vv.


I'm using cargo 1.63.0-nightly (4d92f07f3 2022-06-09)

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

1 Answers1

0

--nocapture

The right invocation here is

cargo test -- --nocapture

From the docs,

By default the Rust test harness hides output from test execution to keep results readable. Test output can be recovered (e.g., for debugging) by passing --nocapture to the test binaries:

cargo test -- --nocapture

I've opened Issue #10777 on GitHub to suggest changing this behavior

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468