smith-tests
Testing standards and TDD workflow. Use when writing tests, running test suites, implementing TDD, or organizing test files. Covers unit vs integration test separation, pytest patterns, and test-driven development methodology.
When & Why to Use This Skill
This Claude skill establishes a comprehensive framework for testing standards and Test-Driven Development (TDD) workflows. It provides structured guidance on organizing unit and integration tests, implementing pytest patterns, and maintaining high code quality through a rigorous 'test-before-code' methodology. By enforcing consistent directory structures and environment configurations, it helps developers build more reliable, maintainable, and regression-proof software.
Use Cases
- Implementing Test-Driven Development (TDD): Guiding the workflow of writing failing tests before implementation to ensure code meets specific requirements from the start.
- Test Suite Organization: Structuring project directories to mirror source code for unit tests while maintaining separate, marked integration tests for external services.
- Automated Quality Assurance: Running and verifying full test suites using modern Python package managers like Poetry or uv to ensure zero regressions after code changes.
- PR Review & Coverage Analysis: Identifying critical testing gaps and behavioral coverage issues during the code review process to maintain high engineering standards.
- Environment Configuration: Setting up isolated testing environments, managing conftest.py files, and handling environment variables securely via .env templates.
| name | smith-tests |
|---|---|
| description | Testing standards and TDD workflow. Use when writing tests, running test suites, implementing TDD, or organizing test files. Covers unit vs integration test separation, pytest patterns, and test-driven development methodology. |
Testing Standards
- Load if: Writing tests, running test suites, TDD
- Prerequisites: @smith-principles/SKILL.md, @smith-standards/SKILL.md,
@smith-python/SKILL.md
CRITICAL (Primacy Zone)
- 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 after changes
- 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
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
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-dev/SKILL.md- Development workflow (quality gates)- @smith-principles/SKILL.md - Core principles
ACTION (Recency Zone)
Run tests (Poetry):
poetry run pytest tests/unit/ -v
poetry run pytest tests/integration/ -v
Run tests (uv):
uv run pytest tests/unit/ -v
Success criteria:
- All new functionality has tests
- Test names follow project conventions
- Tests are isolated and deterministic
- No regressions in existing tests