Skip to main content

openlark_core/testing/
mod.rs

1//! 现代化测试基础设施模块
2//!
3//! 提供类型安全的测试工具,消除测试中的 unwrap() 调用,建立清晰的测试模式。
4//!
5//! # 模块结构
6//!
7//! - [`assertions`]:类型安全的断言宏系统
8//! - [`fixtures`]:统一的测试夹具和配置构建器
9//! - [`mock_context`]:Mock 服务器配置和测试运行时
10//!
11//! # 使用示例
12//!
13//! ```rust,ignore
14//! use openlark_core::testing::prelude::*;
15//!
16//! #[test]
17//! fn test_example() {
18//!     let config = TestConfigBuilder::new().build();
19//!     let rt = TestRuntime::new();
20//!
21//!     let result = rt.block_on(async { some_api().await });
22//!     let response = assert_res_ok!(result, "test_example");
23//!     assert_eq!(response.id, "123");
24//! }
25//! ```
26
27pub mod assertions;
28pub mod fixtures;
29pub mod mock_context;
30
31#[cfg(test)]
32pub mod mock_server;
33
34/// 测试工具预置模块
35///
36/// 包含常用的测试配置构建器和运行时工具
37pub mod prelude {
38    pub use super::fixtures::{test_config, TestConfigBuilder};
39    pub use super::mock_context::{test_runtime, TestRuntime};
40
41    #[cfg(test)]
42    pub use super::mock_server::TestServer;
43
44    // 宏通过 #[macro_export] 自动导出,不需要 pub use
45}