How to set the --nocapture flag for all Rust/Cargo tests in IntelliJ?

Viewed 2078

Is there a way to make IntelliJ's/CLion's Rust plugin use the --nocapture flag for Rust tests?

I see I could create a "Run" configuration for each test, but that's not scalable.

Also, IntelliJ used to print the Cargo command it was running for tests. Now the output window just shows Testing started at 15:31 ...

2 Answers

You can customise the template for all configurations. Please enable Show stdout/stderr in tests (and disable tool window) option on the Run | Edit Configurations tab: screenshot

For command line usage add an alias:

.cargo/config:

[alias]
t = "test -- --nocapture"

run with:

$ cargo t

Or to preserve color:

[alias]
t = "test -- --nocapture --color always"
Related