有没有一种方法可以让IntelliJ/CLion Rust插件在Rust测试中使用--nocapture标志?我知道我可以为每个测试创建“运行”配置,但那不可扩展。此外,IntelliJ以前会打印它正在运行的测试的Cargo命令。现在输出窗口只显示“Testing started at 15:31 ...”
要在命令行中使用,请添加别名:
.cargo/config:
[alias]
t = "test -- --nocapture"
使用以下命令运行:
$ cargo t
或者保留颜色:
[alias]
t = "test -- --nocapture --color always"
--nocapture
标志的方法。RUST_TEST_NOCAPTURE
环境变量设置为除0
以外的任何值,你将获得输出结果。你不需要--nocapture
标志。
参考: https://doc.rust-lang.org/rustc/tests/index.html#--nocapture