Test Design
by @sydpz
Test design and strategy skill for comprehensive testing. Use when: designing test cases, planning testing strategy, writing unit/integration/e2e tests, or i...
clawhub install test-designπ About This Skill
name: test-design description: > Test design and strategy skill for comprehensive testing. Use when: designing test cases, planning testing strategy, writing unit/integration/e2e tests, or improving test coverage. Triggers: test design, test strategy, unit test, integration test, e2e test, TDD, test coverage, test plan, test case design. Provides: testing pyramid guidance, test case templates, test categorization, mocking strategies, and test execution frameworks.
Test Design Skill
A structured approach to designing tests that give confidence without excessive maintenance burden.
Core Philosophy
Test behavior, not implementation. Tests that couple to internal implementation details become fragile and refactor-resistant. Aim to test what the code does, not how it does it.
The best test is the one that fails when something breaks, and passes when everything works. Perfect coverage means nothing if tests don't catch real bugs.
Testing Pyramid
βββββββββββ
β E2E β β Few, slow, high confidence
ββ΄ββββββββββ΄β
β Integrationβ β Some, medium speed
ββ΄ββββββββββββ΄β
β Unit β β Many, fast, granular
βββββββββββββββ
Unit tests form the base β fast, isolated, cover individual functions. Integration tests verify components work together. E2E tests validate complete user journeys.
Test Case Design
Arrange-Act-Assert (AAA) Pattern
def test_withdraw_amount_exceeds_balance():
# Arrange
account = Account(balance=Decimal("100.00"))
# Act
result = account.withdraw(Decimal("150.00"))
# Assert
assert result.is_failed()
assert account.balance == Decimal("100.00") # unchanged
Given-When-Then (GWT) Pattern
Feature: Account Withdrawal Scenario: Withdrawal amount exceeds balance
Given an account with balance $100
When I withdraw $150
Then the withdrawal is rejected
And the balance remains $100
Test Categories
π΄ Happy Path Tests
π‘ Edge Case Tests
π‘ Error Case Tests
π’ Edge/Extreme Cases
Test Doubles (Mocks/Stubs/Fakes)
| Type | Purpose | Use When | |------|---------|----------| | Dummy | Fill parameter lists | Never actually used | | Stub | Provide predetermined responses | Test requires specific data | | Spy | Record how something was called | Verify interactions | | Mock | Pre-programmed expectations | Verify behavior + interactions | | Fake | Working implementation (simplified) | Real impl too slow/complex |
Rule: Prefer real objects over mocks when practical. Mocks hide integration problems.
Test Naming Convention
test___
Examples:
test_user_create_with_valid_input_succeedstest_user_create_with_duplicate_email_failstest_order_cancel_after_shipment_refunds_full_amountCoverage Targets
| Layer | Target | Purpose | |-------|--------|---------| | Unit | 70-80% | Core business logic | | Integration | 40-60% | Key flows work together | | E2E | Critical paths only | User journeys |
Note: Coverage is a guide, not a goal. 100% coverage with shallow tests is worse than 70% with meaningful assertions.
Test Execution
Unit Tests
Run frequently during development (every save).# Go
go test ./...Python
pytest tests/unit/ -vTypeScript
npm test -- --coverage
Integration Tests
Run before PR, after unit tests pass.# Start dependencies
docker-compose up -dRun integration suite
pytest tests/integration/ -v
E2E Tests
Run on CI against deployed environment.# CI/CD pipeline
npm run test:e2e -- --specs=critical-paths
Test Data Management
Strategies
1. Factories/Fixtures β Create test data on demand 2. Seeded Data β Deterministic test datasets 3. Randomized Data β Fuzz testing with random inputs 4. Snapshot Testing β Verify serializable outputsBest Practices
File Structure
test-design/
βββ SKILL.md
βββ references/
βββ test-case-templates.md
βββ testing-pyramid.md
βββ mocking-strategies.md
βββ test-naming-conventions.md
βββ per-type/
βββ unit-test-guide.md
βββ integration-test-guide.md
βββ e2e-test-guide.md