#unit #benchmark #integration #test #path

asmov-testing

创建文件的备份.bak副本

6个版本 (3个稳定版)

2.1.4 2024年6月14日
1.1.3 2024年6月12日
0.1.2 2024年6月5日
0.1.1 2024年6月5日
0.1.0 2024年6月5日

#210 in 测试

Download history 328/week @ 2024-06-05 441/week @ 2024-06-12 43/week @ 2024-06-19 33/week @ 2024-07-03 1/week @ 2024-07-17 29/week @ 2024-07-24

每月63次下载

GPL-3.0-or-later

87KB
1.5K SLoC

Asmov Testing

Latest Version

用于Rust有组织测试的工具包。

功能

  • 将测试结构化为层次结构
    • 模块
    • 分组
    • 测试
  • 允许在每个级别上进行细粒度的设置和拆卸回调。
  • 标准化临时和固定目录的文件路径辅助工具。

示例用法

#[cfg(test)]
mod tests {
    use std::fs;
    use asmov_testing::{self as testing, prelude::*};

    static TESTING: testing::StaticModule = testing::module(|| {
        testing::integration(module_path!())
            .using_temp_dir()
            .using_fixture_dir()
            .setup(|module| {
                let tmp_file = module.temp_dir()
                    .join("hello.txt");
                fs::write(&tmp_file,
                    "Hello, Temp").unwrap();
            })
            .teardown_static(teardown)
            .build()
    });

    extern fn teardown() {
        println!("Farewell, sweet test run");
    }

    #[named]
    #[test]
    fn test_things() {
        let test = TESTING.test(function_name!())
            .using_fixture_dir()  
            .inherit_temp_dir()
            .build();

        let temp_file = test.temp_dir()
            .join("hello.txt");
        let temp_text = fs::read_to_string(temp_file)
            .unwrap();
        assert_eq!("Hello, Temp", temp_text);

        let fixture_file = test.fixture_dir()
            .join("sample.txt");
        let _fixture_text = fs::read_to_string(fixture_file)
            .unwrap();
        assert_eq!("Hello, Fixture", _fixture_text);
    }
}

文档

请参阅 docs.rs/asmov-testing

许可(GPL 3)

Asmov Testing:用于Rust有组织测试的工具包
版权(C)2023 Asmov LLC

本程序是自由软件:您可以在自由软件基金会发布的GNU通用公共许可证的条款下重新分发和/或修改它,无论是许可证的第3版,还是(按您的选择)任何较新版本。

本程序按“希望它有用”的原则分发,但没有任何保证;甚至没有隐含的对适销性或特定用途适用性的保证。有关详细信息,请参阅GNU通用公共许可证。

您应该已经收到与本程序一起的GNU通用公共许可证副本。如果没有,请参阅https://gnu.ac.cn/licenses/

第三方许可证

crate: function_name

我们的库公开导出了Daniel Henry-Mantilla的crate中的命名宏:function_name。它可以从我们的crate作为asmov_testing::named使用。

许可(MIT)
版权(c)2019 Daniel Henry-Mantilla

依赖关系

~4–5MB
~93K SLoC