From autonomous-dev
Guides TDD workflows, pytest unit/integration/UAT testing strategies, test pyramid organization, coverage requirements, and GenAI validation for code quality.
How this skill is triggered — by the user, by Claude, or both
Slash command
/autonomous-dev:skills/testing-guideThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Comprehensive testing strategies including TDD, traditional pytest testing, GenAI validation, and system performance meta-analysis.
arrange-act-assert.mdcoverage-strategies.mddocs/ci-cd-integration.mddocs/progression-testing.mddocs/pytest-fixtures-coverage.mddocs/regression-testing.mddocs/tdd-methodology.mddocs/test-organization-best-practices.mddocs/testing-layers.mddocs/three-layer-strategy.mddocs/workflow-hybrid-approach.mdpytest-patterns.mdtest-templates/fixture-examples.pytest-templates/integration-test-template.pytest-templates/unit-test-template.pyComprehensive testing strategies including TDD, traditional pytest testing, GenAI validation, and system performance meta-analysis.
Modern testing approach combining traditional pytest, GenAI validation, and system performance meta-analysis.
Layer 1: Traditional Tests (pytest)
Layer 2: GenAI Validation (Claude)
Layer 3: System Performance Testing (Meta-analysis)
See: docs/three-layer-strategy.md for complete framework and decision matrix
Four-layer testing pyramid from fast unit tests to comprehensive GenAI validation.
Layers:
Testing Pyramid:
/\ Layer 4: GenAI Validation (comprehensive)
/ \
/UAT \ Layer 3: UAT Tests (few, slow)
/______\
/Int Tests\ Layer 2: Integration Tests (some, medium)
/__________\
/Unit Tests \ Layer 1: Unit Tests (many, fast)
See: docs/testing-layers.md for detailed layer descriptions and examples
Recommended workflow combining automated testing with manual verification.
Development Phase:
Pre-Commit (Automated):
Pre-Release (Manual):
See: docs/workflow-hybrid-approach.md for complete workflow and hybrid testing patterns
Test-Driven Development: Write tests before implementation.
TDD Workflow:
Benefits:
Test Pass Requirement:
Coverage Targets (separate from pass rate):
See: docs/tdd-methodology.md for detailed TDD workflow and test patterns
Track performance improvements over time with baseline comparisons.
Purpose:
How It Works:
See: docs/progression-testing.md for baseline format and test templates
Prevent fixed bugs from reappearing.
When to Create:
Regression Test Template:
def test_regression_issue_123_handles_empty_input():
"""
Regression test for Issue #123: Handle empty input gracefully.
Previously crashed with KeyError on empty dict.
"""
# Arrange
empty_input = {}
# Act
result = process(empty_input)
# Assert
assert result == {"status": "empty"}
See: docs/regression-testing.md for complete patterns and organization
Tests are automatically marked based on directory location. No manual @pytest.mark needed!
Tier Structure:
tests/
├── regression/
│ ├── smoke/ # Tier 0: Critical path (<5s) - CI GATE
│ ├── regression/ # Tier 1: Feature protection (<30s)
│ ├── extended/ # Tier 2: Deep validation (<5min)
│ └── progression/ # Tier 3: TDD red phase
├── unit/ # Unit tests (isolated functions)
├── integration/ # Integration tests (multi-component)
├── security/ # Security-focused tests
├── hooks/ # Hook-specific tests
└── archived/ # Obsolete tests (excluded)
Where to Put New Tests:
Is it protecting a released feature?
├─ Yes → Critical path (install, sync, load)?
│ ├─ Yes → tests/regression/smoke/
│ └─ No → tests/regression/regression/
└─ No → TDD red phase (not implemented)?
├─ Yes → tests/regression/progression/
└─ No → Single function/class?
├─ Yes → tests/unit/{subcategory}/
└─ No → tests/integration/
Run by Tier:
pytest -m smoke # CI gate (must pass)
pytest -m regression # Feature protection
pytest -m "smoke or regression" # Both
pytest -m unit # Unit tests only
Validate Categorization:
python scripts/validate_test_categorization.py --report
See: docs/TESTING-TIERS.md for complete tier definitions and examples
Directory structure, naming conventions, and testing best practices.
Naming Conventions:
test_*.pytest_*test_feature_v{VERSION}_{name}.pytest_ prefix)See: docs/test-organization-best-practices.md for detailed conventions and best practices
Common fixtures for setup/teardown and coverage measurement strategies.
Common Fixtures:
tmp_path - Temporary directorymonkeypatch - Mock environment variablescapsys - Capture stdout/stderrCoverage Targets:
Check Coverage:
pytest --cov=src --cov-report=term-missing
See: docs/pytest-fixtures-coverage.md for fixture patterns and coverage strategies
Automated testing in pre-push hooks and GitHub Actions.
Pre-Push Hook:
#!/bin/bash
pytest tests/ || exit 1
GitHub Actions:
- name: Run tests
run: pytest tests/ --cov=src --cov-report=xml
See: docs/ci-cd-integration.md for complete CI/CD integration patterns
| Pattern | Use Case | Details |
|---|---|---|
| Test Tiers | Auto-categorization | docs/TESTING-TIERS.md |
| Three-Layer Strategy | Complete testing approach | docs/three-layer-strategy.md |
| Testing Layers | Pytest pyramid | docs/testing-layers.md |
| TDD Methodology | Test-first development | docs/tdd-methodology.md |
| Progression Testing | Performance tracking | docs/progression-testing.md |
| Regression Testing | Bug prevention | docs/regression-testing.md |
| Test Organization | Directory structure | docs/test-organization-best-practices.md |
| Pytest Fixtures | Setup/teardown patterns | docs/pytest-fixtures-coverage.md |
| CI/CD Integration | Automated testing | docs/ci-cd-integration.md |
| Tier | Directory | Time Limit | Purpose |
|---|---|---|---|
| 0 (Smoke) | regression/smoke/ | <5s | CI gate, critical path |
| 1 (Regression) | regression/regression/ | <30s | Feature protection |
| 2 (Extended) | regression/extended/ | <5min | Deep validation |
| 3 (Progression) | regression/progression/ | - | TDD red phase |
| Unit | unit/ | <1s | Isolated functions |
| Integration | integration/ | <30s | Multi-component |
| Test Type | Speed | When to Use | Coverage Target |
|---|---|---|---|
| Unit | Fast (ms) | Pure functions, deterministic logic | 90%+ |
| Integration | Medium (sec) | Component interactions, workflows | 70%+ |
| UAT | Slow (min) | End-to-end scenarios, critical paths | Key flows |
| GenAI Validation | Slow (min) | Architecture validation, design review | As needed |
This skill uses progressive disclosure to prevent context bloat:
docs/*.md files with implementation details (loaded on-demand)Available Documentation:
docs/three-layer-strategy.md - Modern three-layer testing frameworkdocs/testing-layers.md - Four-layer testing pyramiddocs/workflow-hybrid-approach.md - Development and testing workflowdocs/tdd-methodology.md - Test-driven development patternsdocs/progression-testing.md - Performance baseline trackingdocs/regression-testing.md - Bug prevention patternsdocs/test-organization-best-practices.md - Directory structure and conventionsdocs/pytest-fixtures-coverage.md - Pytest patterns and coveragedocs/ci-cd-integration.md - Automated testing integrationRelated Skills:
Related Tools:
regression/smoke/ = CI gatetest_<function>_<scenario>_<expected>python scripts/validate_test_categorization.pynpx claudepluginhub akaszubski/autonomous-dev --plugin autonomous-devGuides test pyramid structure, coverage targets, and patterns for unit, integration, and E2E tests. Includes AAA pattern, naming conventions, and API test checklist.
Design testing strategies (unit, integration, end-to-end, performance) that catch bugs without creating bottlenecks. Use when scaling testing or improving release confidence.
Provides test design patterns, coverage strategies (80-100% targets), types (unit/integration/E2E), organization, and best practices for comprehensive test suites. Use for new suites, coverage improvement, or test design.