# 搜索引擎测试流水线指南 本文档是测试套件的**权威入口**,涵盖目录约定、运行方式、回归锚点矩阵、以及手动 联调脚本的分工。任何与这里不一致的历史文档(例如提到 `tests/unit/` 或 `scripts/start_test_environment.sh`)都是过期信息,以本文为准。 ## 1. 测试目录与分层 ``` tests/ ├── conftest.py # 只做 sys.path 注入;不再维护全局 fixture ├── ci/ # API/服务契约(FastAPI TestClient + 全 fake 依赖) │ └── test_service_api_contracts.py ├── manual/ # 需真实服务才能跑的联调脚本,pytest 默认不 collect │ ├── test_build_docs_api.py │ ├── test_cnclip_service.py │ └── test_facet_api.py └── test_*.py # 子系统单测(全部自带 fake,无外部依赖) ``` 关键约束(写在 `pytest.ini` 里,不要另起分支): - `testpaths = tests`,`norecursedirs = tests/manual`; - `--strict-markers`:所有 marker 必须先在 `pytest.ini::markers` 登记; - 测试**不得**依赖真实 ES / DeepL / LLM 服务。需要外部依赖的脚本请放 `tests/manual/`。 ## 2. 运行方式 | 场景 | 命令 | 覆盖范围 | |------|------|----------| | CI 门禁(每次提交) | `./scripts/run_ci_tests.sh` | `tests/ci` + `contract` marker + `search ∧ regression` | | 发版 / 大合并前 | `./scripts/run_regression_tests.sh` | 所有 `@pytest.mark.regression` | | 子系统子集 | `SUBSYSTEM=search ./scripts/run_regression_tests.sh` | 指定子系统的 regression 锚点 | | 全量(含非回归) | `python -m pytest tests/ -q` | 全部自动化用例 | | 手动联调 | `python tests/manual/