用途
test-generator 是一个测试生成技能,用于为项目生成测试套件。其触发词覆盖 test、測試、寫測試、coverage、覆蓋率、pytest、unittest、驗證、TG、unit test、整合測試、e2e、static、ruff、mypy、lint,说明它同时面向测试编写与静态分析两类任务。
主要能力
静态分析
资料列出四种静态分析工具及其用途与命令:
- ruff:Linter + Formatter,命令为
uv run ruff check src/ --fix && uv run ruff format src/ - mypy:类型检查,命令为
uv run mypy src/ --ignore-missing-imports - bandit:安全扫描,命令为
uv run bandit -r src/ -ll - vulture:死代码检测,命令为
uv run vulture src/ --min-confidence 80
完整命令为:uv run ruff check src/; uv run mypy src/ --ignore-missing-imports; uv run bandit -r src/ -ll
测试金字塔
资料按层级给出工具与目录约定:
- Unit:pytest,目录 tests/unit/
- Integration:pytest + httpx,目录 tests/integration/
- E2E:playwright,目录 tests/e2e/
- Coverage:pytest-cov,目标 ≥80%
单元测试必涵盖
- Happy Path — 正常流程
- Edge Cases — 边界条件
- Error Handling — pytest.raises
- Parametrize — @pytest.mark.parametrize
使用方式
资料给出的执行命令如下:
pytest tests/unit -v # 單元
pytest tests/integration -v -m integration # 整合
pytest --cov=src --cov-report=term-missing --cov-fail-under=80 # 覆蓋率
检查清单
- Happy path + edge cases + error handling
- Fixtures 設定(conftest.py)
- 覆蓋率 ≥ 80%
- CI workflow 整合
适用场景
适用于需要生成或补全测试套件的 Python 项目,尤其是希望按单元、整合、E2E 分层组织测试,并同时运行 ruff、mypy、bandit、vulture 等静态分析工具的场景。
限制
资料未提供该技能的安装方式、依赖版本、平台支持范围、收费信息或具体效果数据,这些内容暂未提供。