Test Generation Skill
Static Analysis
| Tool |
Purpose |
Command |
| ruff |
Linter + Formatter |
uv run ruff check src/ --fix && uv run ruff format src/ |
| mypy |
Type Checking |
uv run mypy src/ --ignore-missing-imports |
| bandit |
Security Scanning |
uv run bandit -r src/ -ll |
| vulture |
Dead Code Detection |
uv run vulture src/ --min-confidence 80 |
Complete:uv run ruff check src/; uv run mypy src/ --ignore-missing-imports; uv run bandit -r src/ -ll
Test Pyramid
| Level |
Tool |
Directory |
| Unit |
pytest |
tests/unit/ |
| Integration |
pytest + httpx |
tests/integration/ |
| E2E |
playwright |
tests/e2e/ |
| Coverage |
pytest-cov |
Target ≥80% |
Unit tests must cover
- Happy Path — Normal flow
- Edge Cases — Boundary conditions
- Error Handling —
pytest.raises
- Parametrize —
@pytest.mark.parametrize
Execution Commands
pytest tests/unit -v # 單元
pytest tests/integration -v -m integration # 整合
pytest --cov=src --cov-report=term-missing --cov-fail-under=80 # 覆蓋率
Checklist
- Happy path + edge cases + error handling
- Fixtures setup (conftest.py)
- Coverage ≥ 80%
- CI workflow integration