14 个版本 (4 个稳定版)
1.3.0 | 2022年3月29日 |
---|---|
1.2.0 | 2021年9月22日 |
1.1.0 | 2021年8月14日 |
0.6.0 | 2021年7月28日 |
#843 在 文本处理
每月下载量 36 次
在 2 个crate中使用 (通过 testpath)
20KB
367 代码行
bin-test 的伴随crate,实现测试功能
描述
TestCall 使用 BinTest 和 std::process::Command 将进程执行包装起来,以便在(重复)测试中使用。提供了一些额外的测试功能,并将随着未来的发展而增长。
示例
#[test]
fn myprogram_test() {
let executables = BinTest::new();
let mut myprogram = TestCall::new(&executables, "myprogram");
myprogram
.call(["--help"])
.assert_success();
}
未来计划
根据需要添加新功能,欢迎提交PR。这是一个正在进行中的项目。
lib.rs
:
bin-test 的伴随crate,实现测试功能
描述
TestCall 使用 BinTest 和 std::process::Command 将进程执行包装起来,以便在(重复)测试中使用。提供了一些额外的测试功能,并将随着未来的发展而增长。
初始示例
#[test]
fn myprogram_test() {
let executables = BinTest::new();
let mut myprogram = TestCall::new(&executables, "myprogram");
myprogram
.call(["--version"])
.assert_success()
.assert_stdout_utf8("myprogram 0.1.*");
}
恐慌与结果
'testcall' 明确用于编写测试。为了简化这一过程,它更倾向于通过恐慌而不是错误处理来终止。当发生任何错误时,测试将被终止,并报告原因。
概念和功能
增强标准/现有事物 assert capture regex
正则表达式和捕获
TestCall
允许通过 'bintest' crate 或任何其他可执行文件设置和调用项目构建的程序。增强 'std::process::Command'。测试的运行结果将被收集并返回为 'std::process::Output'。
TestOutput
一个Trait,通过添加断言和正则表达式捕获函数来增强 'std::process::Output',以验证测试运行的输出。注意,'std::process::Output' 将调用结果存储在内存中。因此,测试不应产生过多的输出(在 stdout/stderr 上)。
未来计划
根据需要添加新功能,欢迎提交PR。这是一个正在进行中的项目。
依赖关系
~5–16MB
~201K SLoC