Test creation
Natural invoke
- "Add tests for projects/templates/template_code_project/src/template_code_project/core/optimizer.py"
- "Raise coverage on infrastructure/validation to pass 60% gate"
- "Test this CLI with subprocess, no mocks"
Inputs to confirm
- Code under test — module/path.
- Layer — infrastructure (60%) vs project (90%).
Workflow
- No mocks — never
unittest.mock, MagicMock, or patch the unit under test. Use real computation, tmp_path, local HTTP servers, subprocess for CLIs.
- Structure —
test_*.py mirroring src modules; parametrize variants; fixed RNG seeds.
- Coverage — run pytest-cov; meet floor for layer.
- Integration — wire into
projects/<n>/tests/ or tests/infra_tests/ following existing layout.
Deliverables
- Test file(s) with passing run and coverage report excerpt
- Note any opt-in markers (
requires_latex, requires_ollama)
Verification commands
uv run pytest path/to/test_file.py -v
uv run pytest projects/<project>/tests/ --cov=projects/<project>/src --cov-fail-under=90
uv run pytest tests/infra_tests/path/ --cov=infrastructure --cov-fail-under=60
When NOT to use
References