runbook.md 5.3 KB

CFC · 测试工作 Runbook(发现/跟踪 + 本机执行)

生成日期:2026-11-01 | 模式:discovery-only(发现/跟踪) 本仓库的 tdd-orchestrator 定位为「发现 / 格式化 / 跟踪已有测试」,实际跑测试在开发机完成 (需 mvn / MySQL / 已配好的 Python 环境)。本沙箱负责发现、编目、规划与进度跟踪。 ⚠️ 测试目标环境:http://cfc.iwintrue.com(远程测试环境)。本机跑测试只针对该环境,不指向本地后端 / 不指向生产。

1. 当前测试资产(只读扫描,2026-11-01)

来源 文件数 用例/方法
结构化用例 tests/test-cases/*.md 9 678
Playwright tests/**/*.spec.js 70 411
Python pytest(cfc-langgraph + tools/xaf_agent_hub) 12 47
Java 后端 @Test(cfc-backend/src/test/java) 182 1379
用户场景 tests/user-scenarios/*.md 8 文件级
合计 — 2515

后端 Controller 共 357 个、handler 方法 1933,已覆盖仅 199(10.3%),未覆盖 271 个。

2. 后端覆盖缺口 Backlog(按模块,真实扫描结果)

缺口 = 当前测试源中没有任何 handler 被命中的 Controller。这是发现出的真实缺口,非发明。

模块 未覆盖 总数 覆盖率 优先级
admin(运营后台) 103 120 14% P0
guide(规划师) 14 19 26% P1
family(家庭) 8 15 47% P1
mind(心理) 6 8 25% P2
assessment(测评) 5 6 17% P2
diet / recommendation / fatloss / task / wealth / user 等 各 3–5 0% — P2/P3

admin 占全部未覆盖的约 38%,且多为核心管理接口,补测收益最高。

3. 执行 Runbook(开发机)

3.1 Java 纯单测子集(无需数据库)

cd cfc-backend
mvn -q -DskipTests compile
# 只跑不依赖 Spring 上下文 / 数据库的纯单测包
mvn test -Dtest='com.etotem.cfc.unit.**,com.etotem.cfc.util.**,com.etotem.cfc.common.**'

3.2 Java 集成测试(需 MySQL@3306 + Redis@6379 已起)

cd cfc-backend
mvn test -Dtest='com.etotem.cfc.integration.**'
# 全量(耗时较长,需完整基础设施):
mvn test

3.3 Python(cfc-langgraph)

cd cfc-langgraph
python -m venv .venv && .venv\Scripts\activate
pip install -r requirements.txt pytest pysqlite3   # 含 chromadb/langchain/deepface 等原生重依赖
pytest tests -q

3.4 Playwright E2E / API(针对 cfc.iwintrue.com 测试环境)

项目 Playwright 配置默认已指向测试环境:

  • playwright.config.api.js → baseURL 直接 http://cfc.iwintrue.com(API 级 e2e)
  • playwright.config.js(主) → 默认 http://cfc.iwintrue.com(可用 PW_BASE_URL 覆盖)
  • playwright.config.func.js / playwright.config.smoke.js → 默认 http://127.0.0.1:9082,跑测试环境需显式覆盖
  • e2e_complete_test.py → BASE = http://cfc.iwintrue.com:80
cd tests
npm install
npx playwright install chromium
# 针对测试环境(func/smoke 需带 PW_BASE_URL;api/主配置默认即是)
PW_BASE_URL=http://cfc.iwintrue.com npx playwright test --project=api      # API 级 e2e(默认指向测试环境)
PW_BASE_URL=http://cfc.iwintrue.com npx playwright test --project=smoke    # 冒烟(覆盖 localhost 默认)
PW_BASE_URL=http://cfc.iwintrue.com npx playwright test --project=func     # 功能(覆盖 localhost 默认)
PW_BASE_URL=http://cfc.iwintrue.com npx playwright test                    # 全量
# Python 端到端(已硬编码 cfc.iwintrue.com:80)
python e2e_complete_test.py

4. 推荐执行顺序(先立基线,再补重依赖)

  1. Java 纯单测子集 —— 最快建立通过基线,本地编译运行、不依赖远程(验证代码层,非环境层)。
  2. Python pytest —— 需装完整依赖(较重,原生包可能耗时),本地运行。
  3. Java 集成测试 —— 连测试环境 DB/Redis 或本地基础设施后跑(环境层验证)。
  4. Playwright E2E / API —— 针对 cfc.iwintrue.com 测试环境跑(见 3.4,func/smoke 带 PW_BASE_URL)。

5. 进度跟踪(本沙箱侧车)

  • 进度落 .tdd/test-progress.json,按 anchor = source_path#local_id 索引(如 tests/test-cases/admin.md#TC-A-01)。
  • 执行后在本沙箱跑 test_inventory.py 即从侧车派生 docs/tdd/test/automation-status.md。
  • 原始测试文件零侵入:只改侧车,不改 .md / .spec.js / .py / .java。
  • 发现 / 台账命令(只读):

    python <skill>/discover_tests.py --project d:/cfc
    python <skill>/test_inventory.py --project d:/cfc
    

    <skill> = C:/Users/iwt/.workbuddy/skills/tdd-orchestrator/scripts

6. 优先级与下一步

  • 先补 admin 模块(103 未覆盖,核心管理接口),再 guide / family / mind / assessment。
  • 在开发机执行完任一子集后,把结果回填侧车(通过 / 失败 / 阻塞),再跑 test_inventory.py 刷新共享台账。
  • 所有 E2E / API 测试一律针对 http://cfc.iwintrue.com 测试环境;Java 单测为本地代码层验证,集成测试连测试环境基础设施。
  • 本沙箱不推送 .tdd/;docs/tdd/test/*.md 可提交推送给测试团队。