| Crates.io | xacli-testing |
| lib.rs | xacli-testing |
| version | 0.2.0 |
| created_at | 2025-11-28 18:09:07.24556+00 |
| updated_at | 2026-01-15 18:31:02.765458+00 |
| description | Testing utilities for XaCLI - keyboard simulation, VHS tape parsing, and output capture |
| homepage | |
| repository | https://github.com/yufeiminds/xacli |
| max_upload_size | |
| id | 1955824 |
| size | 135,880 |
这个模块是实现对 App 运行时的包装,实现以下能力:
假设初始化了一个 App 实例 app:
use xacli_core::App;
let app = App::new("myapp");
// ... 初始化该 App
use xacli_testing::TestingApp;
// 创建一个 TestingApp 包装器
let app = TestingApp::new(app);
let t = app
// 返回 TestSuite 可修改的引用
.suite("my_test_suite") // 可选,默认值 default
// 返回 TestCase 可修改的引用
.test("test case 1")
.commands(&["command"])
.args(&["--option", "value"])
.input_events(vec![]) // 如果需要模拟输入事件
let result = t.assert() // 返回 Assert 断言构建器
.stdout(predicate::str::contains("XXX"))
.success(); // 执行测试
let result = t.assert()
.stderr(predicate::str::contains("Error message"))
.failure();
let result = t.assert()
.snapshot("snapshot_name.xaclisnap")
.success();
// 单个测试用例的报告
println!("{}", result);
// 整个测试套件的报告
println!("{}", app.report());