diff --git a/docs/test-guide.md b/docs/test-guide.md index 5401e36..2dae11f 100644 --- a/docs/test-guide.md +++ b/docs/test-guide.md @@ -11,9 +11,10 @@ | 场景 | 命令 | 耗时 | 说明 | |------|------|------|------| | **改了某个模块** | `pytest tests/unit/test_spawner.py` | <5s | 只跑改动的模块对应的单元测试 | -| **改了 API 层** | `pytest tests/integration/` | ~1min | 跑全部集成测试 | -| **提交前快速验证** | `pytest -m "not e2e"` | ~2min | 不跑 E2E,验证不破坏现有功能 | -| **部署前全量验证** | `RUN_INTEGRATION=1 pytest` | ~60min | 含 E2E,真实 Agent | +| **改了 API 层** | `RUN_INTEGRATION=1 pytest tests/integration/` | ~1min | 跑全部集成测试 | +| **提交前快速验证** | `pytest` | ~2min | 默认排除 integration 和 e2e | +| **含集成测试** | `RUN_INTEGRATION=1 pytest` | ~5min | 包含 integration 测试 | +| **部署前全量验证** | `RUN_INTEGRATION=1 pytest` | ~60min | 含 e2e,真实 Agent | | **只跑 E2E 场景** | `RUN_INTEGRATION=1 pytest tests/e2e/test_e2e_scenarios.py` | ~30min | 串行,一个跑完再下一个 | | **只跑 E2E 压力** | `RUN_INTEGRATION=1 pytest tests/e2e/test_e2e_stress.py` | ~10min | 并发测试 | diff --git a/pyproject.toml b/pyproject.toml index 801e0a4..61c214d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,10 @@ requires-python = ">=3.9" asyncio_mode = "auto" testpaths = ["tests"] markers = [ - "integration: real agent tests (requires RUN_INTEGRATION=1)", + "integration: integration tests (requires RUN_INTEGRATION=1)", + "e2e: end-to-end tests with real daemon + Agent (requires RUN_INTEGRATION=1)", ] +addopts = "-m 'not integration and not e2e'" [tool.pyright] venvPath = "." diff --git a/tests/conftest.py b/tests/conftest.py index a1e4aca..ba0bd54 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,6 +55,14 @@ def client_with_isolation(isolated_data_root): # ── E2E gate ── +def pytest_collection_modifyitems(config, items): + if not os.environ.get("RUN_INTEGRATION"): + skip = pytest.mark.skip(reason="needs RUN_INTEGRATION=1") + for item in items: + if "integration" in item.keywords or "e2e" in item.keywords: + item.add_marker(skip) + + skip_no_integration = pytest.mark.skipif( not os.environ.get("RUN_INTEGRATION"), reason="Set RUN_INTEGRATION=1 to run E2E tests against real daemon",