first commit

This commit is contained in:
2026-02-08 14:42:58 +08:00
commit 20e1deae21
8197 changed files with 2264639 additions and 0 deletions

112
tests/README.md Normal file
View File

@@ -0,0 +1,112 @@
# 智能算法展示平台 - 测试指南
本目录包含智能算法展示平台的各种测试,包括单元测试、集成测试和端到端测试。
## 测试目录结构
```
tests/
├── unit_tests/ # 单元测试
├── integration_tests.py # 集成测试
├── integration_test_config.py # 集成测试配置
├── run_tests.py # 测试运行脚本
└── README.md # 本文件
```
## 运行测试
### 1. 使用测试运行脚本
```bash
# 运行所有测试
python tests/run_tests.py --all
# 只运行单元测试
python tests/run_tests.py --unit
# 只运行集成测试
python tests/run_tests.py --integration
# 运行集成测试和端到端测试
python tests/run_tests.py --integration --e2e
# 显示详细输出
python tests/run_tests.py --all --verbose
```
### 2. 环境变量配置
在运行测试之前,建议设置以下环境变量:
```bash
# 测试API密钥
export TEST_API_KEY="your-test-api-key"
# 测试基础URL
export TEST_BASE_URL="http://localhost:8000"
# 测试超时时间(秒)
export TEST_TIMEOUT=30
# 重试次数
export TEST_RETRY_COUNT=3
# OpenAI API密钥如果需要测试OpenAI集成功能
export OPENAI_API_KEY="your-openai-api-key"
```
### 3. 运行特定测试
```bash
# 运行集成测试文件
python tests/integration_tests.py
# 使用unittest模块运行特定测试
python -m unittest tests.integration_tests.TestAlgorithmManagement -v
```
## 集成测试配置
集成测试配置文件 (`integration_test_config.py`) 包含以下配置项:
- `base_url`: API基础URL
- `api_key`: 认证API密钥
- `test_timeout`: 测试超时时间
- `retry_count`: 重试次数
- `test_algorithms`: 预定义的测试算法配置
## 测试类型说明
### 单元测试
- 测试单个函数、类或模块的功能
- 不依赖外部服务
- 快速执行
### 集成测试
- 测试多个组件之间的交互
- 验证API端点的功能
- 需要运行的服务实例
### 端到端测试
- 测试完整的用户场景
- 验证端到端的工作流程
- 需要完整的系统环境
## CI/CD 集成
测试脚本支持CI/CD环境在CI环境中会自动检测并调整配置。
## 故障排除
如果测试失败,请检查:
1. 服务是否正在运行
2. API密钥是否正确配置
3. 数据库连接是否正常
4. 环境变量是否设置正确
## 退出码
- `0`: 所有测试通过
- `1`: 至少一个测试失败
- `2`: 测试执行过程中出现错误