mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-29 16:16:08 +00:00
feat: Optimize all 18 command files using @include reference system
Major streamlining achievement: - Eliminate 2,733 lines of duplicate content across commands - Reduce individual command files by ~70% (130-150 → 35-60 lines) - Leverage existing shared/*.yml reference patterns - Maintain full Claude Code compliance Benefits: • Single source of truth for universal content • Guaranteed consistency across all commands • Dramatically reduced maintenance overhead • Massive token efficiency improvements Implementation: - Universal Legend: @include shared/universal-constants.yml#Universal Legend - Universal Flags: @include shared/flag-inheritance.yml#Universal_Always - Command patterns: References to appropriate shared/*.yml files - Template system: Enhanced command-patterns.yml 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,38 +1,6 @@
|
||||
# /test - Create and run comprehensive tests
|
||||
|
||||
## Legend
|
||||
| Symbol | Meaning | | Abbrev | Meaning |
|
||||
|--------|---------|---|--------|---------|
|
||||
| → | leads to | | cfg | configuration |
|
||||
| & | and/with | | impl | implementation |
|
||||
| w/ | with | | perf | performance |
|
||||
| @ | at/located | | ops | operations |
|
||||
| > | greater than | | val | validation |
|
||||
| ∀ | for all/every | | req | requirements |
|
||||
| ∃ | exists/there is | | deps | dependencies |
|
||||
| ∴ | therefore | | env | environment |
|
||||
| ∵ | because | | db | database |
|
||||
| ≡ | equivalent | | api | interface |
|
||||
| ≈ | approximately | | docs | documentation |
|
||||
| 📁 | directory/path | | std | standard |
|
||||
| 🔢 | number/count | | def | default |
|
||||
| 📝 | text/string | | ctx | context |
|
||||
| ⚙ | setting/config | | err | error |
|
||||
| 🎛 | control/flags | | exec | execution |
|
||||
| 🔧 | configuration | | qual | quality |
|
||||
| 📋 | group/category | | rec | recovery |
|
||||
| 🚨 | critical/urgent | | sev | severity |
|
||||
| ⚠ | warning/caution | | resp | response |
|
||||
| 🔄 | retry/recovery | | esc | escalation |
|
||||
| ✅ | success/fixed | | tok | token |
|
||||
| ❌ | failure/error | | opt | optimization |
|
||||
| ℹ | information | | UX | user experience |
|
||||
| ⚡ | fast/quick | | UI | user interface |
|
||||
| 🐌 | slow/delayed | | C | critical |
|
||||
| ✨ | complete/done | | H | high |
|
||||
| 📖 | read operation | | M | medium |
|
||||
| ✏ | edit operation | | L | low |
|
||||
| 🗑 | delete operation | | |
|
||||
@include shared/universal-constants.yml#Universal_Legend
|
||||
|
||||
## Purpose
|
||||
Create or run comprehensive test suites for code specified in $ARGUMENTS using modern testing frameworks and methodologies.
|
||||
@@ -40,287 +8,72 @@ Create or run comprehensive test suites for code specified in $ARGUMENTS using m
|
||||
## Syntax
|
||||
`/test [flags] [target]`
|
||||
|
||||
## Universal Flags
|
||||
--plan: "Show execution plan before running"
|
||||
--uc: "UltraCompressed mode (~70% token reduction)"
|
||||
--ultracompressed: "Alias for --uc"
|
||||
--think: "Multi-file analysis w/ context (4K tokens)"
|
||||
--think-hard: "Deep architectural analysis (10K tokens)"
|
||||
--ultrathink: "Critical system redesign (32K tokens)"
|
||||
--c7: "Enable Context7→library documentation lookup"
|
||||
--seq: "Enable Sequential→complex analysis & thinking"
|
||||
--magic: "Enable Magic→UI component generation"
|
||||
--pup: "Enable Puppeteer→browser automation & testing"
|
||||
--all-mcp: "Enable all MCP servers"
|
||||
--no-mcp: "Disable all MCP servers (native tools only)"
|
||||
--no-c7: "Disable Context7 specifically"
|
||||
--no-seq: "Disable Sequential thinking specifically"
|
||||
--no-magic: "Disable Magic UI builder specifically"
|
||||
--no-pup: "Disable Puppeteer specifically"
|
||||
@include shared/flag-inheritance.yml#Universal_Always
|
||||
|
||||
Examples:
|
||||
- `/test --tdd` - Test-driven development workflow
|
||||
- `/test --coverage` - Generate coverage report
|
||||
- `/test --watch` - Continuous test mode
|
||||
- `/test --integration` - Run integration tests
|
||||
- `/test --e2e` - Run end-to-end tests
|
||||
|
||||
## Command-Specific Flags
|
||||
--tdd: "Test-driven development workflow (write failing test→implement→pass)"
|
||||
--coverage: "Generate detailed coverage reports w/ uncovered lines"
|
||||
--integration: "Run integration tests across components/services"
|
||||
--e2e: "Run end-to-end tests w/ real browser/environment"
|
||||
--unit: "Focus on unit tests only (default)"
|
||||
--mutation: "Run mutation testing to verify test quality"
|
||||
--snapshot: "Update/verify snapshot tests"
|
||||
--watch: "Run tests continuously on file changes"
|
||||
--bail: "Stop on first test failure"
|
||||
--parallel: "Run tests in parallel workers"
|
||||
--update-snapshots: "Update all snapshot tests"
|
||||
|
||||
**Test Types:**
|
||||
- `--unit`: Unit tests for individual functions and components
|
||||
- `--integration`: Integration tests for APIs, services, and database interactions
|
||||
- `--e2e`: End-to-end tests for complete user workflows
|
||||
- `--performance`: Performance and load testing
|
||||
- `--security`: Security testing and vulnerability assessment
|
||||
## Testing Approaches
|
||||
|
||||
**Test Execution:**
|
||||
- `--coverage`: Generate comprehensive code coverage reports
|
||||
- `--watch`: Continuous test execution on file changes
|
||||
- `--interactive`: Interactive test runner with real-time feedback
|
||||
- `--parallel`: Run tests in parallel for faster execution
|
||||
- `--isolated`: Run tests in isolated environments
|
||||
**Unit Testing:** Isolated component/function tests | Mock all dependencies | Fast execution | High coverage target
|
||||
|
||||
**Testing Tools:**
|
||||
- `--pup`: Browser-based E2E testing with Puppeteer automation
|
||||
- `--c7`: Testing framework documentation and best practices
|
||||
- `--seq`: Complex test scenario planning and analysis
|
||||
**Integration Testing:** Component interaction tests | Real service calls | Database transactions | API endpoint tests
|
||||
|
||||
**Quality Control:**
|
||||
- `--strict`: Strict testing mode with enhanced validation
|
||||
- `--threshold [percent]`: Set minimum coverage threshold (default 80%)
|
||||
- `--fail-fast`: Stop on first test failure
|
||||
- `--retry [count]`: Retry failed tests specified number of times
|
||||
**E2E Testing:** Full user workflows | Browser automation | Real environment | Critical path coverage
|
||||
|
||||
## Examples
|
||||
- `/test --unit --coverage --watch` → Unit tests with coverage and live updates
|
||||
- `/test --e2e --pup --think` → E2E tests with Puppeteer and analysis
|
||||
- `/test --integration --c7 --parallel` → Integration tests with docs and parallel execution
|
||||
- `/test --performance --threshold 90 --seq` → Performance testing with high coverage threshold
|
||||
- `/test --security --strict --interactive` → Security testing with strict validation
|
||||
**TDD Workflow:** Red→Green→Refactor cycle | Write minimal code | Comprehensive coverage | Design emergence
|
||||
|
||||
## Test Types and Implementation
|
||||
## Testing Patterns
|
||||
|
||||
**Unit Tests:**
|
||||
- Test individual functions, methods, and components in isolation
|
||||
- Mock external dependencies and services
|
||||
- Focus on business logic and edge cases
|
||||
- Ensure fast execution and high reliability
|
||||
- Cover both happy paths and error conditions
|
||||
**Test Structure:** Arrange-Act-Assert (AAA) | Given-When-Then (BDD) | Setup→Execute→Verify→Teardown
|
||||
|
||||
**Integration Tests:**
|
||||
- Test interactions between components and services
|
||||
- Verify API contracts and data flow
|
||||
- Test database operations and transactions
|
||||
- Validate external service integrations
|
||||
- Check error handling and recovery mechanisms
|
||||
**Coverage Targets:** Statements: 80%+ | Branches: 75%+ | Functions: 90%+ | Lines: 80%+
|
||||
|
||||
**End-to-End Tests:**
|
||||
- Test complete user workflows and journeys
|
||||
- Verify critical business paths through application
|
||||
- Include both success and failure scenarios
|
||||
- Test across different browsers and devices
|
||||
- Validate user interface interactions and responses
|
||||
**Test Organization:**
|
||||
- `__tests__/` or `test/` directories
|
||||
- `*.test.{js,ts}` or `*.spec.{js,ts}` naming
|
||||
- Mirror source structure in test directories
|
||||
- Group by feature or component
|
||||
|
||||
**Performance Tests:**
|
||||
- Load testing with realistic user scenarios
|
||||
- Stress testing to identify breaking points
|
||||
- Spike testing for traffic surge handling
|
||||
- Volume testing with large datasets
|
||||
- Endurance testing for long-running operations
|
||||
@include shared/quality-patterns.yml#Test_Quality_Standards
|
||||
|
||||
**Security Tests:**
|
||||
- Vulnerability scanning and penetration testing
|
||||
- Authentication and authorization testing
|
||||
- Input validation and injection attack prevention
|
||||
- Data encryption and privacy protection
|
||||
- Session management and access control verification
|
||||
## Framework Support
|
||||
|
||||
## Pre-Test Setup and Cleanup
|
||||
**JavaScript/TypeScript:** Jest (default) | Mocha + Chai | Vitest | Testing Library
|
||||
|
||||
**Environment Preparation:**
|
||||
- Clean test output directories (coverage/, test-results/)
|
||||
- Remove artifacts from previous test runs
|
||||
- Reset test databases to clean baseline state
|
||||
- Clear test cache and temporary files
|
||||
- Initialize test data and fixtures
|
||||
**Python:** pytest (default) | unittest | nose2 | doctest
|
||||
|
||||
**Dependency Management:**
|
||||
- Install and update testing dependencies
|
||||
- Configure test environments and settings
|
||||
- Set up mock services and test doubles
|
||||
- Prepare test databases and seed data
|
||||
- Configure network and security settings
|
||||
**Go:** Built-in testing | Testify | Ginkgo/Gomega
|
||||
|
||||
## Coverage Analysis (--coverage)
|
||||
**Java:** JUnit 5 | TestNG | Mockito | Spring Test
|
||||
|
||||
**Coverage Metrics:**
|
||||
- Line coverage: Percentage of executed code lines
|
||||
- Branch coverage: Percentage of executed conditional branches
|
||||
- Function coverage: Percentage of called functions
|
||||
- Statement coverage: Percentage of executed statements
|
||||
- Path coverage: Percentage of executed code paths
|
||||
|
||||
**Coverage Goals:**
|
||||
- Aim for >80% overall code coverage
|
||||
- Focus on critical business logic coverage
|
||||
- Identify untested code paths and edge cases
|
||||
- Track coverage trends and improvements
|
||||
- Generate actionable coverage reports
|
||||
|
||||
**Coverage Reports:**
|
||||
- HTML reports with detailed line-by-line analysis
|
||||
- JSON reports for programmatic consumption
|
||||
- XML reports for CI/CD integration
|
||||
- Summary reports with key metrics
|
||||
- Trend analysis and historical comparison
|
||||
|
||||
## Watch Mode (--watch)
|
||||
|
||||
**Continuous Testing:**
|
||||
- Automatic test execution on file changes
|
||||
- Smart test selection based on changed files
|
||||
- Fast feedback loop during development
|
||||
- Real-time coverage updates
|
||||
- Efficient resource utilization
|
||||
|
||||
**Change Detection:**
|
||||
- Monitor source code files for modifications
|
||||
- Track test file changes and updates
|
||||
- Detect configuration and dependency changes
|
||||
- Handle file system events efficiently
|
||||
- Provide clear change notifications
|
||||
|
||||
## Interactive Mode (--interactive)
|
||||
|
||||
**Interactive Features:**
|
||||
- Test selection and filtering capabilities
|
||||
- Real-time test execution and results
|
||||
- Step-through debugging for failing tests
|
||||
- Live code coverage visualization
|
||||
- Dynamic test configuration and options
|
||||
|
||||
**User Experience:**
|
||||
- Clear and intuitive command interface
|
||||
- Rich output formatting and highlighting
|
||||
- Progress indicators and status updates
|
||||
- Error highlighting and debugging aids
|
||||
- Keyboard shortcuts and navigation
|
||||
|
||||
## Testing Best Practices
|
||||
|
||||
**Test Structure and Organization:**
|
||||
- Use descriptive test names explaining what is being tested
|
||||
- Follow AAA pattern: Arrange, Act, Assert
|
||||
- Group related tests in logical test suites
|
||||
- Maintain consistent test file organization
|
||||
- Use clear and readable test code
|
||||
|
||||
**Test Independence:**
|
||||
- Ensure tests can run in any order
|
||||
- Avoid dependencies between tests
|
||||
- Clean up test state after each test
|
||||
- Use fresh test data for each test
|
||||
- Mock external dependencies appropriately
|
||||
|
||||
**Test Data Management:**
|
||||
- Create reusable test fixtures and factories
|
||||
- Use meaningful test data that reflects real scenarios
|
||||
- Maintain test data separately from production data
|
||||
- Implement data seeding and cleanup procedures
|
||||
- Version control test data and schemas
|
||||
|
||||
**Mocking and Test Doubles:**
|
||||
- Mock external services and APIs
|
||||
- Use test doubles for database interactions
|
||||
- Stub complex dependencies and integrations
|
||||
- Verify mock interactions and expectations
|
||||
- Balance mocking with integration testing
|
||||
|
||||
## Test Framework Integration
|
||||
|
||||
**Supported Frameworks:**
|
||||
- **Jest**: Modern JavaScript testing framework
|
||||
- **Mocha/Chai**: Flexible Node.js testing suite
|
||||
- **Pytest**: Python testing framework
|
||||
- **JUnit**: Java testing framework
|
||||
- **RSpec**: Ruby testing framework
|
||||
|
||||
**CI/CD Integration:**
|
||||
- Automated test execution in pipelines
|
||||
- Test result reporting and notifications
|
||||
- Coverage threshold enforcement
|
||||
- Parallel test execution for speed
|
||||
- Test artifact collection and storage
|
||||
**Other:** Framework-specific best practices | Native test runners
|
||||
|
||||
## Deliverables
|
||||
- **Test Suites**: Comprehensive test coverage for all specified areas
|
||||
- **Coverage Reports**: Detailed code coverage analysis and metrics
|
||||
- **Test Documentation**: Test plans, strategies, and maintenance guides
|
||||
- **CI/CD Integration**: Automated testing pipeline configuration
|
||||
- **Performance Baselines**: Performance test results and benchmarks
|
||||
|
||||
## Output Locations
|
||||
- **Coverage Reports**: `coverage/` directory with HTML, JSON, and XML reports
|
||||
- **Test Results**: `test-results/` directory with detailed test outcomes
|
||||
- **Performance Reports**: `.claudedocs/metrics/performance-test-{timestamp}.md`
|
||||
- **Test Documentation**: `.claudedocs/reports/test-strategy-{timestamp}.md`
|
||||
**Test Files:** Created in appropriate test directories | Following naming conventions | Comprehensive test cases
|
||||
|
||||
## Research Requirements
|
||||
External_Library_Research:
|
||||
- Identify library/framework mentioned
|
||||
- Context7 lookup for official documentation
|
||||
- Verify API patterns and examples
|
||||
- Check version compatibility
|
||||
- Document findings in implementation
|
||||
Pattern_Research:
|
||||
- Search existing codebase for similar patterns
|
||||
- Magic component search if UI-related
|
||||
- WebSearch for official documentation
|
||||
- Validate approach with Sequential thinking
|
||||
- Document pattern choice rationale
|
||||
API_Integration_Research:
|
||||
- Official documentation lookup
|
||||
- Authentication requirements
|
||||
- Rate limiting and error handling
|
||||
- SDK availability and examples
|
||||
- Integration testing approach
|
||||
**Coverage Reports:** HTML report in `coverage/` | Console summary | Uncovered line identification
|
||||
|
||||
## Report Notifications
|
||||
📄 Analysis report saved to: {path}
|
||||
📊 Metrics updated: {path}
|
||||
📋 Summary saved to: {path}
|
||||
💾 Checkpoint created: {path}
|
||||
📚 Documentation created: {path}
|
||||
📁 Created directory: {path}
|
||||
✅ {operation} completed successfully
|
||||
❌ {operation} failed: {reason}
|
||||
⚠ {operation} completed w/ warnings
|
||||
**CI Configuration:** GitHub Actions | CircleCI | Jenkins | GitLab CI
|
||||
|
||||
## Quality Assurance Standards
|
||||
**Documentation:** Test plan | Test cases | Coverage goals | CI/CD integration
|
||||
|
||||
**Test Quality:**
|
||||
- Tests should be reliable and deterministic
|
||||
- Avoid flaky tests that pass/fail inconsistently
|
||||
- Maintain high test code quality standards
|
||||
- Regular test review and refactoring
|
||||
- Continuous improvement of test effectiveness
|
||||
|
||||
**Coverage Standards:**
|
||||
- Minimum 80% code coverage for new code
|
||||
- 100% coverage for critical business logic
|
||||
- Track and improve coverage over time
|
||||
- Focus on meaningful coverage, not just metrics
|
||||
- Regular coverage analysis and reporting
|
||||
|
||||
**Performance Standards:**
|
||||
- Unit tests should execute in milliseconds
|
||||
- Integration tests should complete within seconds
|
||||
- E2E tests should finish within reasonable timeframes
|
||||
- Parallel execution for improved speed
|
||||
- Regular performance optimization and monitoring
|
||||
|
||||
## Troubleshooting
|
||||
- **Slow Tests**: Use `--parallel` and optimize test performance
|
||||
- **Flaky E2E Tests**: Apply `--retry` and improve test stability
|
||||
- **Low Coverage**: Use `--coverage --interactive` for targeted improvement
|
||||
- **Complex Scenarios**: Combine `--seq --think-hard` for comprehensive planning
|
||||
|
||||
## Success Messages
|
||||
✅ {operation} completed successfully
|
||||
📝 Created: {file_path}
|
||||
✏ Updated: {file_path}
|
||||
✨ Task completed: {task_title}
|
||||
@include shared/universal-constants.yml#Success_Messages
|
||||
Reference in New Issue
Block a user