Testing Standards
<metadata>- Load if: Writing tests, running test suites, TDD
- Prerequisites: @smith-principles/SKILL.md, @smith-standards/SKILL.md,
@smith-python/SKILL.md
CRITICAL (Primacy Zone)
<required>- MUST mirror source structure:
foo/bar/xyz.py→tests/unit/foo/bar/test_xyz.py - MUST use pytest functions (not classes) - see
@smith-python/SKILL.md - MUST separate unit (
tests/unit/) and integration (tests/integration/) tests - MUST use virtual env runner for pytest (
poetry runoruv run) - MUST write tests BEFORE implementation (TDD)
- MUST run full test suite proactively after code changes — do not wait for the user to ask
- MUST run the module's quality gate before reporting completion — linting, type checks, and tests (
make quality> project CI script > run individually; see@smith-dev/SKILL.mdPre-PR Quality Gates)
- NEVER use
pytest -m "not integration"if folder structure is mirrored (import conflicts) - NEVER write implementation before tests
- NEVER skip running tests after changes
Test Organization
Unit:
- Location:
tests/unit/ - Characteristics: Mock dependencies, fast
Integration:
- Location:
tests/integration/ - Characteristics: Real services,
@pytest.mark.integration
TDD Workflow
- Understand: Read existing test patterns
- Design: Write failing tests defining expected behavior
- Implement: Write minimal code to pass tests
- Verify: Run tests, validate coverage
- Refactor: Improve code while keeping tests green
Environment Configuration
tests/conftest.pydisables tracking (OPIK, etc.)- Virtual env runners load
.envautomatically - Use
.env.exampleas template (NEVER commit.env)
Claude Code Plugin Integration
<context>When pr-review-toolkit is available:
- pr-test-analyzer agent: Analyzes behavioral coverage, identifies critical gaps
- Rates test gaps 1-10 (10 = critical, must add)
- Trigger: "Check if the tests are thorough" or use Task tool
Ralph Loop Integration
<context>TDD = Ralph iteration: test → implement → pytest → iterate until <promise>TESTS PASS</promise>.
See @smith-ralph/SKILL.md for full patterns.
@smith-python/SKILL.md- Python testing patterns (pytest functions)@smith-playwright/SKILL.md- Playwright failure monitoring@smith-dev/SKILL.md- Development workflow (quality gates)- @smith-principles/SKILL.md - Core principles
ACTION (Recency Zone)
<required>Run tests (use project's virtual env runner):
VENV_RUNNER pytest tests/unit/ -v
VENV_RUNNER pytest tests/integration/ -v
VENV_RUNNER = poetry run, uv run, etc. — check project CLAUDE.md or pyproject.toml.
Success criteria:
- All new functionality has tests
- Test names follow project conventions
- Tests are isolated and deterministic
- No regressions in existing tests