internal/skills/content/testing-strategy/SKILL.md
Test planning and coverage strategy workflow. Use when designing test suites, establishing coverage targets, planning TDD approaches, or assessing testing gaps in existing codebases.
npx skillsauth add ar4mirez/samuel testing-strategyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Systematic test planning and coverage improvement workflow.
| Trigger | Description | |---------|-------------| | Post-COMPLEX Feature | After implementing major features | | Coverage Drop | When coverage falls below thresholds | | Test Debt Sprint | Dedicated testing improvement effort | | New Project | Establishing testing foundation | | Pre-Release | Ensuring quality before deployment |
| Category | Target | Warning | Critical | |----------|--------|---------|----------| | Business Logic | >80% | 70-80% | <70% | | Overall | >60% | 50-60% | <50% | | Critical Paths | >90% | 80-90% | <80% |
Before starting:
Phase 1: Coverage Analysis
↓
Phase 2: Critical Path Identification
↓
Phase 3: Test Pyramid Planning
↓
Phase 4: Test Prioritization
↓
Phase 5: Edge Case Planning
↓
Phase 6: Flaky Test Remediation
↓
Phase 7: Implementation Roadmap
Node.js (Jest/Vitest):
npm test -- --coverage
# or
npx vitest run --coverage
Python (pytest):
pytest --cov=src --cov-report=html
Go:
go test -cover ./...
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
Rust:
cargo tarpaulin --out Html
Review coverage report for:
| Area | Target | Current | Gap |
|------|--------|---------|-----|
| src/auth/ | 90% | 45% | -45% |
| src/api/ | 80% | 62% | -18% |
| src/utils/ | 60% | 78% | +18% |
| Overall | 60% | 55% | -5% |
List files with lowest coverage:
Lowest Coverage Files:
1. src/auth/oauth.ts - 12% (critical!)
2. src/api/payments.ts - 28% (critical!)
3. src/services/email.ts - 35%
4. src/utils/validation.ts - 42%
5. src/api/users.ts - 48%
Critical paths are user journeys that MUST work:
| Path | Description | Files | Priority | |------|-------------|-------|----------| | Authentication | Login, logout, session | auth/* | P0 | | Checkout | Cart → Payment → Confirm | payments/, cart/ | P0 | | Registration | Signup → Verify → Profile | users/, email/ | P1 | | Search | Query → Results → Filter | search/, api/ | P1 |
For each critical path, list involved files:
Authentication Path:
src/auth/login.ts - 45% coverage
src/auth/session.ts - 52% coverage
src/auth/middleware.ts - 88% coverage
src/models/user.ts - 72% coverage
Authentication Path:
- Total lines: 450
- Covered lines: 267
- Coverage: 59% (target: 90%)
- Gap: 183 lines to cover
/\
/ \
/ E2E \ 10% - Slow, expensive, covers user flows
/______\
/ \
/Integration\ 20% - Medium speed, covers integrations
/______________\
/ \
/ Unit Tests \ 70% - Fast, cheap, covers logic
/____________________\
Analyze current test distribution:
Current State:
- Unit tests: 45 (60%)
- Integration: 25 (33%)
- E2E: 5 (7%)
Ideal State:
- Unit tests: 70 (70%)
- Integration: 20 (20%)
- E2E: 10 (10%)
Gap:
- Need +25 unit tests
- Need -5 integration tests (or OK)
- Need +5 E2E tests
Unit Tests (70%):
Integration Tests (20%):
E2E Tests (10%):
| Priority | Criteria | Example | |----------|----------|---------| | P0 | Critical path, no tests | Payment processing | | P1 | Critical path, low coverage | Authentication | | P2 | High risk, medium coverage | Data validation | | P3 | Medium risk, any coverage | Utility functions | | P4 | Low risk, nice to have | Formatting helpers |
| Test Type | Effort | Coverage Impact | |-----------|--------|-----------------| | Unit (simple) | 15 min | High | | Unit (complex) | 1 hour | High | | Integration | 2 hours | Medium | | E2E | 4 hours | Low (but valuable) |
## Test Backlog
### P0 - Immediate (This Sprint)
- [ ] Unit: payment.processPayment()
- [ ] Unit: auth.validateToken()
- [ ] Integration: POST /api/payments
- [ ] E2E: Complete checkout flow
### P1 - High (Next Sprint)
- [ ] Unit: auth.refreshToken()
- [ ] Unit: user.validateEmail()
- [ ] Integration: GET /api/users/:id
- [ ] E2E: Registration flow
### P2 - Medium (Backlog)
- [ ] Unit: validation helpers
- [ ] Unit: formatting utilities
- [ ] Integration: Search API
### P3 - Low (Nice to Have)
- [ ] Unit: logging utilities
- [ ] Unit: config loaders
Every function should test:
| Category | Cases | Example |
|----------|-------|---------|
| Null/Undefined | null, undefined input | validateUser(null) |
| Empty | "", [], {} | searchUsers("") |
| Boundary | 0, -1, MAX_INT | setQuantity(0) |
| Invalid Type | Wrong type input | calculatePrice("abc") |
| Concurrent | Race conditions | Parallel updates |
For each function:
Signs of flaky tests:
| Cause | Symptom | Fix | |-------|---------|-----| | Timing | Random timeouts | Use proper async/await | | Order dependency | Fails when run alone | Reset state in beforeEach | | Shared state | Random failures | Isolate test data | | External services | Network failures | Mock external calls | | Date/time | Fails at midnight | Mock dates |
## Sprint 1: Critical Path (2 weeks)
### Goals
- Achieve 90% coverage on authentication
- Achieve 90% coverage on payments
- Add 5 E2E tests for critical paths
### Tasks
1. Unit tests for auth module (20 tests)
2. Unit tests for payment module (15 tests)
3. Integration tests for auth API (5 tests)
4. E2E test: Complete checkout (1 test)
5. E2E test: Login flow (1 test)
### Expected Outcome
- Overall coverage: 55% → 65%
- Critical path coverage: 59% → 90%
Test Structure:
describe('Module or Function', () => {
// Setup
beforeEach(() => {
// Reset state
});
describe('method or scenario', () => {
it('should [expected behavior] when [condition]', () => {
// Arrange
const input = createTestInput();
// Act
const result = functionUnderTest(input);
// Assert
expect(result).toEqual(expectedOutput);
});
});
});
Naming Convention:
should [expected behavior] when [condition]
Examples:
- should return user when valid ID provided
- should throw error when user not found
- should update timestamp when saving
Track coverage weekly:
| Week | Overall | Business | Critical | Tests Added | |------|---------|----------|----------|-------------| | 1 | 55% | 62% | 59% | +15 | | 2 | 62% | 75% | 78% | +22 | | 3 | 68% | 82% | 88% | +18 | | 4 | 72% | 85% | 92% | +12 |
# Node.js
npm test -- --coverage --coverageReporters=text-summary
# Python
pytest --cov=src --cov-report=term-missing
# Go
go test -cover ./... | grep -E "coverage:"
# Rust
cargo tarpaulin --out Stdout
Unit Test:
describe('functionName', () => {
it('should [behavior] when [condition]', () => {
const result = functionName(input);
expect(result).toEqual(expected);
});
});
Integration Test:
describe('POST /api/resource', () => {
it('should create resource when valid data', async () => {
const response = await request(app)
.post('/api/resource')
.send(validData);
expect(response.status).toBe(201);
});
});
For detailed examples, patterns, and in-depth guidance, see:
references/process.md - Comprehensive testing patterns and examplescode-review - Includes test validationrefactoring - Tests enable safe refactoringtroubleshooting - When tests fail unexpectedlydevelopment
Zig language guardrails, patterns, and best practices for AI-assisted development. Use when working with Zig files (.zig), build.zig, or when the user mentions Zig. Provides comptime patterns, allocator conventions, C interop guidelines, and testing standards specific to this project's coding standards.
tools
WordPress framework guardrails, patterns, and best practices for AI-assisted development. Use when working with WordPress projects, or when the user mentions WordPress. Provides theme development, plugin architecture, REST API, blocks, and security guidelines.
tools
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs. Use when testing web apps, automating browser interactions, or debugging frontend issues.
tools
Suite of tools for creating elaborate, multi-component web applications using modern frontend technologies (React, Tailwind CSS, shadcn/ui). Use for complex projects requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX pages.