如何在 IntelliJ 中为所有 Rust/Cargo 测试设置 --nocapture 标志?

问题描述 投票:0回答:3

有没有办法让 IntelliJ/CLion 的 Rust 插件使用

--nocapture
标志进行 Rust 测试?

我看到我可以为每个测试创建一个“运行”配置,但那是不可扩展的。

此外,IntelliJ 过去常常打印它正在运行的 Cargo 命令以进行测试。现在输出窗口只显示

Testing started at 15:31 ...

intellij-idea rust clion rust-cargo
3个回答
5
投票

您可以为所有配置自定义模板。请启用

Show stdout/stderr in tests (and disable tool window)
选项卡上的
Run | Edit Configurations
选项:screenshot


1
投票

对于命令行用法添加别名:

.cargo/config:

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

运行:

$ cargo t

或保持颜色:

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

0
投票

找不到

Cargo Command
Show stdout/stderr in tests (and disable tool window)
选项的人:

转到

Run/Edit Configurations/Edit Configuration Templates...
,选择
Cargo
并将
-- --nocapture
添加到
Command
字段。不要介意或删除现有的
run
命令。

© www.soinside.com 2019 - 2024. All rights reserved.