12 个版本 (5 个重大更新)
0.5.0 | 2023 年 12 月 28 日 |
---|---|
0.4.3 | 2023 年 12 月 2 日 |
0.4.2 | 2023 年 11 月 25 日 |
0.3.0 | 2023 年 10 月 5 日 |
0.0.0-placeholder | 2022 年 11 月 4 日 |
338 在 开发工具 中排名
每月 4,627 次下载
14KB
217 行
Marker UI-test
测试代码检查的最简单方法是在示例中运行它们并查看生成的输出。作为程序员,我们有自动化此过程的工具。 marker_uitest 是 ui_test crate 的包装,用于 Marker。它执行运行 ui-tests 所需的所有常见设置魔法。
先决条件
marker_uitest 需要 Cargo、rustup 和 cargo_marker 已安装。
用法
ui_test crate 在 tests
目录中的每个 .rs
-文件上运行 Marker,并将输出与旁边的 .stderr
和 .stdout
文件进行比较。要自动更新 .stderr
和 .stdout
文件,您可以使用以下命令或设置 RUST_BLESS
环境变量:
有关支持的完整功能列表和魔法注释,请参阅 ui_test crate 的文档。
设置
清单文件
首先将 marker_utils
添加到代码检查 crate 的 dev-dependencies,并指定 ui-test 不需要测试框架,如下所示:
[dev-dependencies]
marker_uitest = "0.5.0"
[[test]]
name = "uitest"
harness = false
设置测试文件
在 tests
目录中创建一个 uitest.rs
文件。然后您可以使用以下模板开始:
use marker_uitest::ui_test::*;
use std::{env, path::Path};
fn main() -> color_eyre::Result<()> {
let mut config = marker_uitest::simple_ui_test_config!()?;
// Allows you to automatically update `.stderr` and `.stdout` files
let bless = env::var_os("RUST_BLESS").is_some() || env::args().any(|arg| arg == "--bless");
if bless {
config.output_conflict_handling = OutputConflictHandling::Bless
}
// Maybe define replacement filters
config.stderr_filter(r"\\", "/");
config.stdout_filter(r"\\", "/");
// Run the test
run_tests_generic(
config,
default_file_filter,
default_per_file_config,
status_emitter::Text,
)
}
贡献
我们非常欢迎贡献!如果您遇到任何问题或有改进建议,请查看 Marker 的 GitHub 仓库。
许可
版权所有 (c) 2022-2023 Rust-Marker
Rust-marker遵循MIT许可证或Apache许可证(版本2.0)的条款。
依赖关系
约12-24MB
约346K SLoC