tests/
├── integration/ # 集成测试
│ ├── runner.py # 测试执行器
│ ├── cases.json # 测试用例配置
│ └── report.py # 报告生成(待实现)
├── utils/ # 工具模块
│ ├── cli.py # CLI 封装
│ └── compare.py # 结果对比
└── README.md # 本文档
不带交易所后缀:
- 期货:IF2406, RB2405
- 期权:10004697, 510300
- 基金:510300
带交易所后缀:
- A股:000001.XSHE, 600519.XSHG
- 指数:000300.XSHG, 000905.XSHG, 000852.XSHG
- 港股:00700.XHKG
export RQDATA_USERNAME="your_username"
export RQDATA_PASSWORD="your_password"# 运行所有测试
/home/lhz/.miniconda3/envs/zz1000/bin/python tests/integration/runner.py
# 运行指定套件
/home/lhz/.miniconda3/envs/zz1000/bin/python tests/integration/runner.py --suite index
# 运行 P0 优先级测试
/home/lhz/.miniconda3/envs/zz1000/bin/python tests/integration/runner.py --priority P0测试用例定义在 tests/integration/cases.json:
{
"suites": {
"index": [
{
"id": "idx-001",
"name": "单指数日线行情",
"priority": "P0",
"cmd": "index price",
"payload": {...},
"python": "rqdatac.get_price(...)",
"validate": {"min_rows": 1}
}
]
}
}当遇到参数错误时,使用 --schema 查看正确的参数定义:
# 查看命令的 schema
./build/rqdata fund nav --schema
# 查看期权合约的 schema
./build/rqdata options contracts --schema根据 schema 中的参数定义,在 tests/integration/cases.json 中添加用例:
{
"id": "test-001",
"name": "测试描述",
"priority": "P0",
"cmd": "fund nav",
"payload": {
"order_book_ids": ["510300"],
"start_date": "2024-01-02"
},
"python": "rqdatac.fund.get_nav('510300', '2024-01-02')",
"validate": {"min_rows": 1}
}/home/lhz/.miniconda3/envs/zz1000/bin/python tests/integration/runner.py --suite fundGitHub Actions 工作流:
- 快速测试:每次 PR(P0 用例)
- 完整测试:每日定时 + Release