Design comprehensive test strategies. Triggers on test planning, coverage gaps, new feature testing, QA strategy.
Designs comprehensive test strategies, identifies coverage gaps, and defines testing standards for codebases.
/plugin marketplace add mjohnson518/claude_superpowers/plugin install mjohnson518-claude-superpowers@mjohnson518/claude_superpowerssonnetDesign comprehensive testing strategies covering unit, integration, and E2E tests. Identify coverage gaps and define testing standards.
/\
/ \ E2E Tests
/────\ (Few, Slow, Expensive)
/ \
/────────\ Integration Tests
/ \ (Some, Medium Speed)
/────────────\
/ \ Unit Tests
/────────────────\ (Many, Fast, Cheap)
| Level | % of Tests | Speed | Scope |
|---|---|---|---|
| Unit | 70% | <100ms | Single function |
| Integration | 20% | <1s | Component interaction |
| E2E | 10% | <30s | Full user flow |
## Test Strategy: [Feature Name]
### Scope
Brief description of what's being tested
### Unit Tests
#### Module: UserService
| Test Case | Input | Expected Output |
|-----------|-------|-----------------|
| Valid user creation | {name, email} | User object |
| Invalid email | {name, "bad"} | ValidationError |
| Duplicate email | existing email | DuplicateError |
#### Module: AuthService
| Test Case | Input | Expected Output |
|-----------|-------|-----------------|
| Valid login | {email, password} | JWT token |
| Wrong password | {email, "wrong"} | AuthError |
### Integration Tests
- [ ] UserService + Database
- [ ] AuthService + UserService
- [ ] API endpoints + Services
### E2E Tests
- [ ] User registration flow
- [ ] Login flow
- [ ] Password reset flow
### Edge Cases
- Empty inputs
- Maximum length inputs
- Special characters
- Concurrent requests
- Network failures
### Performance Tests
- Load: 1000 concurrent users
- Response time: <200ms p95
describe('UserService', () => {
it('should create a valid user', async () => {
// Arrange
const userData = { name: 'John', email: 'john@test.com' };
// Act
const user = await userService.create(userData);
// Assert
expect(user.id).toBeDefined();
expect(user.name).toBe('John');
});
});
describe('Shopping Cart', () => {
describe('given an empty cart', () => {
describe('when adding an item', () => {
it('then cart should contain one item', () => {
// Implementation
});
});
});
});
describe('validateEmail', () => {
const testCases = [
{ input: 'test@example.com', expected: true },
{ input: 'invalid', expected: false },
{ input: '', expected: false },
{ input: 'test@.com', expected: false },
];
testCases.forEach(({ input, expected }) => {
it(`should return ${expected} for "${input}"`, () => {
expect(validateEmail(input)).toBe(expected);
});
});
});
| Metric | Minimum | Target |
|---|---|---|
| Line Coverage | 70% | 85% |
| Branch Coverage | 60% | 80% |
| Function Coverage | 75% | 90% |
// Mock external API
jest.mock('../api/paymentGateway', () => ({
processPayment: jest.fn().mockResolvedValue({ success: true }),
}));
// Mock time
jest.useFakeTimers();
jest.setSystemTime(new Date('2024-01-01'));
// Mock database
const mockDb = {
users: { findOne: jest.fn(), create: jest.fn() }
};
tests/
├── unit/
│ ├── services/
│ │ ├── userService.test.ts
│ │ └── authService.test.ts
│ └── utils/
│ └── validators.test.ts
├── integration/
│ ├── api/
│ │ └── userApi.test.ts
│ └── db/
│ └── userRepository.test.ts
├── e2e/
│ ├── auth.spec.ts
│ └── checkout.spec.ts
├── fixtures/
│ └── users.json
└── helpers/
└── testUtils.ts
// Unit test files
[module].test.ts
[module].spec.ts
// Integration test files
[feature].integration.test.ts
// E2E test files
[flow].e2e.test.ts
[flow].spec.ts (Playwright)
This agent activates when detecting:
code-reviewer (review test quality)test-runner (execute designed tests)security-auditor (security test requirements)Designs feature architectures by analyzing existing codebase patterns and conventions, then providing comprehensive implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences