test-strategy
Create testing pyramid with unit/integration/E2E strategy. Define coverage targets and high-risk testing. Use when planning tests for features.
от sethdford★ 51 звезда на GitHub
Установить test-strategy в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Test Strategy
Systematic approach to test planning: pyramid structure (70% unit, 20% integration, 10% E2E), coverage targets (70-80%), and risk-based testing.
Context
You are planning test coverage for a feature. Your role is to:
- Design test pyramid: unit (fast, isolated) > integration (slower, real) > E2E (slowest, brittle)
- Identify high-risk code needing extra testing
- Set realistic coverage targets
- Balance speed (fast feedback) vs confidence (comprehensive testing)
- Avoid the "test everything" trap
Good testing builds confidence, not false security. 100% coverage often means testing trivia instead of business logic.
Domain Context
Based on Martin Fowler, Google Testing, and J.B. Rainsberger:
- Test Pyramid: Most tests at bottom (unit), fewer at middle (integration), few at top (E2E)
- Coverage Target: 70-80% code coverage sufficient; 100% is waste
- Business Value: Test what users care about; not every code path
- High-Risk Code: Auth, payment, data integrity → extra testing
- Speed: Unit tests <100ms; integration <1s; E2E <10s each
When to Use This Skill
- Planning tests for a new feature
- Adding tests to existing codebase
- Auditing test coverage (too little or too much)
- Improving test speed (too slow)
- Preparing for high-risk deployments
Prerequisites
- Understand feature requirements and acceptance criteria
- Know the domain (what's valuable to test vs trivial)
- Have testing tools/frameworks available
- Can run tests locally in <5 seconds
Instructions (Detailed)
1. Define Layers
Unit Tests (70% of tests):
- Single function/method in isolation
- Mock external dependencies
- Run in <1ms each
- Example:
test_calculate_discount_rate_returns_0_05_for_vip()
Integration Tests (20% of tests):
- Component interaction with real dependencies
- Database, file system, real (test) services
- Run in <1s each
- Example:
test_user_registration_saves_to_database()
E2E Tests (10% of tests):
- Full flow through system (UI → API → database)
- Real browser/client, real servers
- Run in <10s each
- Example:
test_checkout_flow_creates_order_and_sends_confirmation()
2. Identify High-Risk Code
Ask: "What breaks the business?"
High-risk areas:
- Authentication/Authorization: Wrong user gets access
- Payment Processing: Charges wrong amount or double-charges
- Data Integrity: Corrupt or lost data
- Critical Flows: Core business logic
- Security: SQL injection, XSS, secrets leaked
Low-risk areas:
- Formatting (display logic)
- Trivial getters/setters
- Framework boilerplate
- Error messages (non-security)
3. Set Coverage Target
Realistic targets:
- High-risk code: 90%+ coverage
- Core logic: 80%+ coverage
- General code: 70-80% coverage
- Framework code: 50% coverage (don't over-test)
Total target: 70-80% for whole codebase.
Don't chase 100%. Diminishing returns: 80% coverage catches 95% of bugs; last 20% coverage catches 4% of bugs but takes 50% of effort.
4. Plan Unit Tests
For each function/method:
- Happy path: Normal input, expected output
- Edge cases: Boundary values (0, 1, -1, max, min)
- Error cases: Invalid input, exceptions
Example (Order::apply_discount):
- Happy path: valid discount code → correct reduction
- Edge case: discount = 100% → total = $0
- Error case: invalid code → raises exception
5. Plan Integration Tests
For each business flow:
- Happy path: Complete flow succeeds
- Dependency failure: Database down, service timeout
- Data consistency: Changes persist correctly
Example (User registration):
- Happy path: register → user saved → email sent
- Database failure: registration fails gracefully
- Duplicate email: rejected with clear error
6. Plan E2E Tests
For critical user journeys only:
- Checkout flow: Add to cart → checkout → payment → confirmation
- Login flow: Enter credentials → authorize → redirect to dashboard
- Report generation: Select criteria → generate → download
Avoid: Every button click, every error message, every combination. E2E tests are brittle and slow.
7. Define Test Data Strategy
- Fixtures: Reusable test data (predefined users, products)
- Factories: Generate test data on-the-fly
- Mocks: Fake dependencies
- Test Databases: Real database with test schema
8. Document Coverage Goals
Create a matrix showing coverage targets:
| Area | Unit | Integration | E2E | Coverage Target |
|---|---|---|---|---|
| User registration | 10 | 3 | 1 | 90% |
| Payment processing | 15 | 5 | 1 | 95% |
| Reporting | 5 | 2 | 1 | 70% |
Output Format
When planning tests, deliver:
- Test Pyramid: Counts for unit/integration/E2E
- Coverage Targets: By risk area
- Unit Test Plan: What
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
- 01
Read - 02
Grep - 03
Glob - 04
Write - 05
Edit - 06
Bash
Вложенные файлы
- examples/example-output.md
- template.md
FAQ
Что делает скилл test-strategy?
Create testing pyramid with unit/integration/E2E strategy. Define coverage targets and high-risk testing. Use when planning tests for features.
Как установить скилл test-strategy?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл test-strategy запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…