274 lines
7.5 KiB
Markdown
274 lines
7.5 KiB
Markdown
# 🧪 Gemini AI - OpenBB集成测试验证工作说明书
|
||
|
||
## 🎯 任务概述
|
||
作为测试工程师,您需要为OpenBB与稷下学宫系统的集成功能设计并执行全面的测试验证方案。
|
||
|
||
## 📋 核心职责
|
||
|
||
### 1. 测试策略制定
|
||
**任务目标:** 制定全面的测试策略和验证标准
|
||
|
||
**测试金字塔设计:**
|
||
```
|
||
[E2E Tests] # 端到端测试
|
||
/ \
|
||
[Integration Tests] # 集成测试
|
||
/ \
|
||
[Unit Tests] [API Tests] # 单元测试 + API测试
|
||
```
|
||
|
||
**测试覆盖范围:**
|
||
- 功能测试 (80%覆盖率)
|
||
- 性能测试 (响应时间、并发)
|
||
- 稳定性测试 (长时间运行)
|
||
- 兼容性测试 (多数据源)
|
||
|
||
### 2. 八仙智能体测试
|
||
**任务目标:** 验证八仙角色的数据获取和分析能力
|
||
|
||
**测试文件结构:**
|
||
```
|
||
tests/immortal_tests/
|
||
├── test_immortal_data_routing.py # 八仙数据路由测试
|
||
├── test_immortal_preferences.py # 八仙偏好测试
|
||
├── test_debate_data_quality.py # 辩论数据质量测试
|
||
└── test_cultural_accuracy.py # 文化准确性测试
|
||
```
|
||
|
||
**关键测试用例:**
|
||
```python
|
||
class TestImmortalDataRouting:
|
||
"""八仙数据路由测试"""
|
||
|
||
def test_lv_dongbin_technical_analysis(self):
|
||
"""测试吕洞宾的技术分析数据获取"""
|
||
pass
|
||
|
||
def test_he_xiangu_risk_metrics(self):
|
||
"""测试何仙姑的风险指标数据"""
|
||
pass
|
||
|
||
def test_immortal_data_consistency(self):
|
||
"""测试八仙数据的一致性"""
|
||
pass
|
||
```
|
||
|
||
### 3. OpenBB集成测试
|
||
**任务目标:** 验证OpenBB数据源的集成质量
|
||
|
||
**测试重点:**
|
||
- OpenBB API调用稳定性
|
||
- 数据格式标准化
|
||
- 错误处理机制
|
||
- 降级策略验证
|
||
|
||
**核心测试文件:**
|
||
```python
|
||
# tests/openbb_integration/
|
||
class TestOpenBBIntegration:
|
||
"""OpenBB集成测试套件"""
|
||
|
||
@pytest.mark.asyncio
|
||
async def test_stock_data_retrieval(self):
|
||
"""测试股票数据获取"""
|
||
symbols = ['AAPL', 'TSLA', 'MSFT']
|
||
for symbol in symbols:
|
||
data = await engine.get_stock_data(symbol)
|
||
assert data is not None
|
||
assert 'close' in data.columns
|
||
|
||
def test_fallback_mechanism(self):
|
||
"""测试OpenBB不可用时的降级机制"""
|
||
# 模拟OpenBB不可用
|
||
with mock.patch('openbb.obb', side_effect=ImportError):
|
||
result = engine.get_data_with_fallback('AAPL')
|
||
assert result.source == 'demo_data'
|
||
```
|
||
|
||
### 4. 性能和稳定性测试
|
||
**任务目标:** 确保系统在各种条件下的性能表现
|
||
|
||
**性能基准:**
|
||
- 数据获取延迟 < 3秒
|
||
- 并发处理 > 10 req/s
|
||
- 内存使用 < 500MB
|
||
- 99.9% 可用性
|
||
|
||
**负载测试方案:**
|
||
```python
|
||
# tests/performance/
|
||
class TestPerformance:
|
||
"""性能测试套件"""
|
||
|
||
def test_concurrent_data_requests(self):
|
||
"""并发数据请求测试"""
|
||
import concurrent.futures
|
||
|
||
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
||
futures = [executor.submit(self.get_test_data) for _ in range(100)]
|
||
results = [f.result() for f in futures]
|
||
|
||
assert all(r.success for r in results)
|
||
assert max(r.response_time for r in results) < 5.0
|
||
```
|
||
|
||
## 🎭 文化特色测试
|
||
|
||
### 八仙文化准确性验证:
|
||
```python
|
||
class TestCulturalAccuracy:
|
||
"""文化准确性测试"""
|
||
|
||
def test_immortal_characteristics(self):
|
||
"""验证八仙特征的准确性"""
|
||
immortals = get_immortal_configs()
|
||
|
||
# 验证吕洞宾的技术分析特色
|
||
assert immortals['吕洞宾'].specialty == 'technical_analysis'
|
||
assert immortals['吕洞宾'].element == '乾'
|
||
|
||
# 验证何仙姑的风险控制特色
|
||
assert immortals['何仙姑'].specialty == 'risk_metrics'
|
||
assert immortals['何仙姑'].element == '坤'
|
||
|
||
def test_debate_cultural_context(self):
|
||
"""验证辩论的文化背景准确性"""
|
||
debate = create_test_debate('AAPL')
|
||
|
||
# 确保辩论遵循稷下学宫的传统
|
||
assert 'jixia' in debate.context
|
||
assert len(debate.participants) == 8 # 八仙
|
||
```
|
||
|
||
## 🔧 测试工具和框架
|
||
|
||
### 推荐工具栈:
|
||
```python
|
||
# 测试依赖
|
||
pytest>=7.4.0 # 主测试框架
|
||
pytest-asyncio>=0.21.0 # 异步测试支持
|
||
pytest-mock>=3.11.0 # Mock功能
|
||
pytest-cov>=4.1.0 # 覆盖率统计
|
||
pytest-benchmark>=4.0.0 # 性能基准测试
|
||
|
||
# 性能测试
|
||
locust>=2.15.0 # 负载测试
|
||
memory-profiler>=0.60.0 # 内存分析
|
||
|
||
# 数据验证
|
||
pydantic>=2.0.0 # 数据模型验证
|
||
jsonschema>=4.19.0 # JSON架构验证
|
||
```
|
||
|
||
### 测试配置文件:
|
||
```yaml
|
||
# pytest.ini
|
||
[tool:pytest]
|
||
testpaths = tests
|
||
python_files = test_*.py
|
||
python_classes = Test*
|
||
python_functions = test_*
|
||
addopts =
|
||
--cov=src
|
||
--cov-report=html
|
||
--cov-report=term-missing
|
||
--asyncio-mode=auto
|
||
```
|
||
|
||
## 📊 测试报告和指标
|
||
|
||
### 测试报告模板:
|
||
```
|
||
tests/reports/
|
||
├── unit_test_report.html # 单元测试报告
|
||
├── integration_test_report.html # 集成测试报告
|
||
├── performance_benchmark.json # 性能基准数据
|
||
├── coverage_report/ # 代码覆盖率报告
|
||
└── cultural_validation_report.md # 文化验证报告
|
||
```
|
||
|
||
### 关键指标监控:
|
||
```python
|
||
# 自动化指标收集
|
||
class TestMetrics:
|
||
"""测试指标收集器"""
|
||
|
||
def collect_response_times(self):
|
||
"""收集响应时间数据"""
|
||
pass
|
||
|
||
def measure_memory_usage(self):
|
||
"""监控内存使用情况"""
|
||
pass
|
||
|
||
def validate_data_quality(self):
|
||
"""验证数据质量指标"""
|
||
pass
|
||
```
|
||
|
||
## 🔄 协作流程
|
||
|
||
### 与Claude的协作:
|
||
1. **接收代码实现** → 制定对应测试用例
|
||
2. **执行测试验证** → 反馈BUG和优化建议
|
||
3. **性能测试** → 提供优化方向
|
||
|
||
### 与Qwen的协作:
|
||
1. **验证架构设计** → 确认技术指标可达成
|
||
2. **测试架构决策** → 验证设计的合理性
|
||
|
||
### 与RovoDev的协作:
|
||
1. **提供测试数据** → 支持文档编写
|
||
2. **验证文档准确性** → 确保文档与实际一致
|
||
|
||
## 📅 测试里程碑
|
||
|
||
### 阶段一(2天):测试框架搭建
|
||
- [ ] 测试环境配置
|
||
- [ ] 基础测试框架
|
||
- [ ] Mock数据准备
|
||
|
||
### 阶段二(3天):功能测试执行
|
||
- [ ] 单元测试执行
|
||
- [ ] 集成测试验证
|
||
- [ ] 八仙特色功能测试
|
||
|
||
### 阶段三(2天):性能和稳定性测试
|
||
- [ ] 负载测试执行
|
||
- [ ] 性能基准建立
|
||
- [ ] 稳定性验证
|
||
|
||
### 阶段四(1天):测试报告生成
|
||
- [ ] 测试结果汇总
|
||
- [ ] 问题清单整理
|
||
- [ ] 优化建议制定
|
||
|
||
## 🎯 验收标准
|
||
|
||
### 功能验收:
|
||
- [ ] 所有单元测试通过率 > 95%
|
||
- [ ] 集成测试通过率 > 90%
|
||
- [ ] 八仙特色功能100%验证通过
|
||
|
||
### 性能验收:
|
||
- [ ] 响应时间 < 3秒
|
||
- [ ] 并发处理 > 10 req/s
|
||
- [ ] 内存使用稳定
|
||
- [ ] 99%可用性达成
|
||
|
||
### 文化验收:
|
||
- [ ] 八仙角色特征准确
|
||
- [ ] 辩论逻辑符合传统
|
||
- [ ] 文化表达尊重得体
|
||
|
||
## 💡 创新测试方法
|
||
|
||
### 智能化测试:
|
||
1. **AI驱动的测试用例生成**
|
||
2. **自适应性能基准调整**
|
||
3. **文化语境的自动化验证**
|
||
4. **用户行为模拟测试**
|
||
|
||
---
|
||
|
||
**注意:** 测试不仅是质量保障,更是文化传承的守护者!每一个测试用例都要体现对传统文化的尊重! |