#测试数据 #辅助 #运行时 #基于文件 #展开

testdata-rt

基于文件的测试辅助工具 -- 通用运行时

1 个不稳定版本

0.1.0 2022年9月25日

#684测试


用于 2 crate

MIT/Apache

28KB
776

testdata-rs

文件测试的宏和辅助函数。

示例

该 crate 的主要功能是 testdata::files,它可以自动查找测试文件并展开为多个测试。

use std::str;
use testdata::{assert_snapshot, TestFile};

#[testdata::files(rebuild = "tests/example.rs")]
#[test]
fn test_foo(
    #[glob = "tests/fixtures/**/*-in.txt"] input: &TestFile,
    #[glob = "tests/fixtures/**/*-out.txt"] output: &TestFile,
) {
    let s = input.raw_read();
    let s = str::from_utf8(&s).unwrap();
    let result = s.to_uppercase();
    assert_snapshot!(result, snapshot = output);
}

后续版本将添加更多文档。


lib.rs:

testdata crate 定义的运行时。

依赖项

~1.4–10MB
~83K SLoC