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-placeholder2022 年 11 月 4 日

338开发工具 中排名

Download history 2679/week @ 2024-04-07 1680/week @ 2024-04-14 2747/week @ 2024-04-21 2262/week @ 2024-04-28 806/week @ 2024-05-05 1809/week @ 2024-05-12 1261/week @ 2024-05-19 1683/week @ 2024-05-26 2382/week @ 2024-06-02 1902/week @ 2024-06-09 1382/week @ 2024-06-16 486/week @ 2024-06-23 1125/week @ 2024-06-30 1199/week @ 2024-07-07 702/week @ 2024-07-14 1599/week @ 2024-07-21

每月 4,627 次下载

MIT/Apache

14KB
217

Marker UI-test

Crates.io License: MIT OR Apache-2.0

测试代码检查的最简单方法是在示例中运行它们并查看生成的输出。作为程序员,我们有自动化此过程的工具。 marker_uitestui_test crate 的包装,用于 Marker。它执行运行 ui-tests 所需的所有常见设置魔法。

先决条件

marker_uitest 需要 Cargorustupcargo_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)的条款。

请参阅LICENSE-APACHELICENSE-MIT

依赖关系

约12-24MB
约346K SLoC