Skip to main content

Module testing

Module testing 

Source
Expand description

现代化测试基础设施模块

提供类型安全的测试工具,消除测试中的 unwrap() 调用,建立清晰的测试模式。

§模块结构

  • assertions:类型安全的断言宏系统
  • fixtures:统一的测试夹具和配置构建器
  • mock_context:Mock 服务器配置和测试运行时

§使用示例

use openlark_core::testing::prelude::*;

#[test]
fn test_example() {
    let config = TestConfigBuilder::new().build();
    let rt = TestRuntime::new();

    let result = rt.block_on(async { some_api().await });
    let response = assert_res_ok!(result, "test_example");
    assert_eq!(response.id, "123");
}

Modules§

assertions
类型安全的断言宏系统
fixtures
统一测试夹具系统
mock_context
Mock 服务器配置和测试运行时
prelude
测试工具预置模块