Loading...
Loading...
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 skill4agent add ar4mirez/samuel testing-strategy| 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% |
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 Roadmapnpm test -- --coverage
# or
npx vitest run --coveragepytest --cov=src --cov-report=htmlgo test -cover ./...
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.outcargo tarpaulin --out Html| Area | Target | Current | Gap |
|---|---|---|---|
| 90% | 45% | -45% |
| 80% | 62% | -18% |
| 60% | 78% | +18% |
| Overall | 60% | 55% | -5% |
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%| 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 |
src/auth/login.ts - 45% coverage
src/auth/session.ts - 52% coverage
src/auth/middleware.ts - 88% coverage
src/models/user.ts - 72% coverageAuthentication 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
/____________________\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| 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| Category | Cases | Example |
|---|---|---|
| Null/Undefined | null, undefined input | |
| Empty | "", [], {} | |
| Boundary | 0, -1, MAX_INT | |
| Invalid Type | Wrong type input | |
| Concurrent | Race conditions | Parallel updates |
| 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%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);
});
});
});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| 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 Stdoutdescribe('functionName', () => {
it('should [behavior] when [condition]', () => {
const result = functionName(input);
expect(result).toEqual(expected);
});
});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);
});
});references/process.mdcode-reviewrefactoringtroubleshooting