继续完善测试模板

This commit is contained in:
2026-05-03 18:08:57 +08:00
parent dd6236866e
commit 4730cd527d
5 changed files with 184 additions and 3 deletions

View File

@@ -5,6 +5,16 @@
- ``python tests/run_tests.py`` 只收集 ``tests/`` 根目录下 ``test_*.py``**不会**进入本目录。
- 本目录下文件一律为 ``*.py.sample``pytest / unittest **默认也不会**按普通 ``test_*.py`` 收集。
## 与 samples 的区别
| 维度 | `tests/samples/` | `tests/integration/` |
|------|------------------|------------------------|
| 目的 | 默认可**升级**为根目录 `test_*.py`**业务单元 / service 契约 / golden** 范式 | **外联联调**范式:网络、浏览器、仿真或真实系统 |
| 默认执行 | `.sample` 不执行;复制到根目录并改名后才进入默认套件 | **永远不**作为默认 unittest 的一部分;复制后仍需显式环境变量与手动/CI 任务触发 |
| 典型内容 | `FakeAdapter`、fixture、隔离 DB | `localhost` 仿真、真实 API授权、真实 RPA最高风险 |
**原则**:只要会访问**网络**、**浏览器**、**真实或仿真外部系统**,应优先放在 `integration`(并保持 `.sample` 直至团队同意启用),而不是写进默认 `tests/test_*.py`
## 何时使用
| 场景 | 建议 ``OPENCLAW_TEST_TARGET`` | 其它条件 |