- 新增8个测试文件(bot_bridge/kpi_causality/cash/predict/reports/tax_compliance/expenses/probe_cost) - 增强 budget/auth/users + conftest账套模式适配 - 测试驱动修复: bot_bridge导入batch_id→source_batch; cash_forecast extra空dict - 全量: 451 passed, 1 xfailed; 报告 docs/cma-test-coverage-report.md
55 lines
2.6 KiB
Markdown
55 lines
2.6 KiB
Markdown
# CMA 自动化测试补覆盖 — 完成报告
|
||
|
||
> 任务:yanxue-cma-auto-tests.md(P1:测试覆盖36% → 60%+)
|
||
> 执行:项目Bot(wecom-project) | 完成:2026-08-20 07:10
|
||
|
||
## 结果总览
|
||
|
||
| 指标 | 任务前 | 任务后 | 验收 |
|
||
|:--|:--:|:--:|:--:|
|
||
| 测试用例数 | 226 | **452**(+226) | - |
|
||
| 全量通过 | - | **451 passed, 1 xfailed** | ✅ |
|
||
| 总覆盖率 | 36% | **60%** | ≥60% ✅ |
|
||
| P0模块(bot_bridge/kpi_causality/budget) | 缺测 | 核心端点全覆盖 | ✅ |
|
||
|
||
## 新增测试文件(8个,全部独立可跑)
|
||
|
||
| 文件 | 覆盖模块 | 说明 |
|
||
|:--|:--|:--|
|
||
| `test_bot_bridge.py` | bot_bridge(P0, 18端点) | Bot访问CMA主通道 |
|
||
| `test_kpi_causality.py` | kpi_causality(P0) | 因果链 CRUD + 推演 |
|
||
| `test_budget.py`(增强) | budget(P0, 15端点) | 预算主流程+边界 |
|
||
| `test_cash.py` | cash(P1) | 现金流 |
|
||
| `test_cost.py`→`test_probe_cost.py` | cost(P1) | 成本分析探针 |
|
||
| `test_predict.py` | predict(P1) | 预测模拟 |
|
||
| `test_reports.py` | reports(P1, 46用例) | 报表中心 |
|
||
| `test_tax_compliance.py` | tax_compliance(P1, 20端点) | 税务合规 |
|
||
| `test_expenses.py` | expenses(P1) | 费用管理 |
|
||
|
||
## 覆盖率明细(app/api 前25)
|
||
|
||
- 100%:permissions / __init__
|
||
- 95%+:users 98 / org 97 / kpi_causality 97 / notifications 96 / reports 94
|
||
- 85-93%:alerts 93 / expenses 92 / bot_bridge 92 / predict 88 / bsc_layers 88 / cost 85 / action_plans 85 / tax_compliance 84 / budget 83
|
||
- 其余:kpi_governance 68 / auth 64 / ai_analysis 56 / dashboard 54 / entities 52 / cash 52 / okr 49 / kpis 44 等(P2 跟进)
|
||
|
||
## 测试发现并修复的 bug(测试驱动)
|
||
|
||
1. `bot_bridge.py`:KPIValue 导入用 `batch_id=`(不存在字段)→ 改 `source_batch=`,bot_import_excel 曾静默失败
|
||
2. `cash_forecast_engine.py`:`extra or {}` 防空 dict + check_cash_alerts 补 KPIDefinition 导入
|
||
3. conftest.py:账套模式 entity_id=1 测试实体 + token 兼容 access_token
|
||
|
||
## 测试数据(博海试验田,entity_id=2)
|
||
|
||
- KPI:BH_REVENUE / BH_NET_PROFIT / BH_COST_RATIO(反向)/ BH_SATISFACTION...
|
||
- 周期:2026-06/07/08;边界:BH_ZERO_TARGET(目标=0)+ 空值KPI
|
||
|
||
## Git
|
||
|
||
- commit:测试补覆盖(见 git log,与本体三支柱任务独立提交,无交叉污染)
|
||
- 注:KPI多粒度功能代码(dashboard.py + 前端3视图)为已上线未提交的历史功能,随本批一并补提交
|
||
|
||
## 遗留(P2 跟进)
|
||
|
||
- 覆盖率不足50%的模块:ai_analysis 56 / dashboard 54 / entities 52 / cash 52 / okr 49 / kpis 44 / data / knowledge 等
|