# Comprehensive Interactive Test Suite for jbuild
This directory contains comprehensive test suites to validate all the new interactive CLI capabilities implemented in jbuild.
## Test Structure
```
tests/
├── interactive_tests.rs # Main comprehensive test suite
├── interactive_unit_tests.rs # Unit tests for interactive functionality
├── interactive_integration_tests.rs # Integration tests with real projects
├── interactive_performance_tests.rs # Performance and stress tests
├── test_utils.rs # Test utilities and helper functions
├── test_config.rs # Test configuration and setup
└── test_interactive.sh # Test runner script
```
## Test Coverage
### 1. Unit Tests (`interactive_unit_tests.rs`)
- **Build Metrics Testing**: Test metrics creation, updating, and tracking
- **Profile Report Generation**: Test JSON, Markdown, and Text report generation
- **Monitor Functions**: Test monitor display and functionality
- **Error Handling**: Test error handling and edge cases
- **Performance Calculations**: Test throughput and timing calculations
### 2. Integration Tests (`interactive_integration_tests.rs`)
- **Project Integration**: Test with Maven and Gradle projects
- **Command Line Interface**: Test all new CLI commands and options
- **Output Formats**: Test all profile output formats (JSON, Markdown, Text)
- **Real-time Monitoring**: Test monitoring functionality
- **Error Handling**: Test error handling with real scenarios
- **Help System**: Test command help functionality
### 3. Performance Tests (`interactive_performance_tests.rs`)
- **Performance Metrics**: Test metrics collection performance
- **Dashboard Rendering**: Test display performance
- **Monitoring Throughput**: Test real-time monitoring performance
- **Concurrent Access**: Test multi-threaded scenarios
- **Large Project Handling**: Test with many files and dependencies
- **Memory and CPU Tracking**: Test resource tracking performance
### 4. Main Test Suite (`interactive_tests.rs`)
- **Comprehensive Testing**: All tests combined
- **End-to-end Validation**: Complete workflow testing
- **Regression Testing**: Prevent regressions in new features
### 5. Test Utilities (`test_utils.rs`)
- **Project Creation**: Create Maven, Gradle, and custom projects
- **Command Execution**: Execute jbuild commands with various options
- **Assertions**: Custom test assertions and utilities
- **Performance Tools**: Time measurement and analysis utilities
### 6. Test Configuration (`test_config.rs`)
- **Test Environment Management**: Create and manage test environments
- **Configuration Options**: Customize test behavior
- **Test Categories**: Organize tests by type
- **Result Tracking**: Test result collection and analysis
## Test Categories
### Unit Tests
- **Build Metrics**: Test metrics tracking and calculations
- **Profile Reports**: Test report generation in all formats
- **Monitoring Functions**: Test monitoring and display functionality
- **Error Handling**: Test error handling and edge cases
- **Performance Calculations**: Test throughput and performance metrics
### Integration Tests
- **Maven Projects**: Test with real Maven project structures
- **Gradle Projects**: Test with real Gradle project structures
- **CLI Commands**: Test all interactive command options
- **Output Formats**: Test all profile output formats
- **Real-time Features**: Test monitoring and dashboard features
- **Help System**: Test command help and documentation
### Performance Tests
- **Metrics Performance**: Test metrics collection speed
- **Display Performance**: Test rendering and update performance
- **Throughput Testing**: Test monitoring update rates
- **Concurrent Testing**: Test multi-threaded scenarios
- **Large Scale**: Test with many files and dependencies
- **Resource Usage**: Test memory and CPU tracking performance
## Running Tests
### Using Cargo
```bash
# Run all tests
cargo test
# Run specific test file
cargo test interactive_unit_tests
# Run with verbose output
cargo test -- --test-threads=1 --nocapture
# Run performance tests
cargo test interactive_performance_tests
# Run integration tests
cargo test interactive_integration_tests
```
### Using Test Script
```bash
# Run comprehensive test suite
./test_interactive.sh
# Run with custom timeout
./test_interactive.sh
```
### Manual Testing
```bash
# Build jbuild
cargo build --bin jbuild
# Test interactive commands
cargo run --bin jbuild -- interactive --help
cargo run --bin jbuild -- monitor --help
cargo run --bin jbuild -- profile --help
# Test with a real project
cargo run --bin jbuild -- interactive --dashboard
cargo run --bin jbuild -- monitor --duration 10
cargo run --bin jbuild -- profile --format json
```
## Test Artifacts
### Generated Files
- **Profile Reports**: JSON, Markdown, and Text reports
- **Test Projects**: Temporary Maven and Gradle projects
- **Output Logs**: Command execution logs and error messages
- **Performance Metrics**: Execution times and throughput data
### Cleanup
- All temporary directories are automatically cleaned up
- Test artifacts are removed after test completion
- Environment variables are properly managed
## Test Validation
### Success Criteria
- All unit tests pass
- Integration tests work with real projects
- Performance tests meet requirements
- Error handling works correctly
- All commands have proper help text
### Quality Metrics
- **Test Coverage**: 95%+ for interactive functionality
- **Performance**: Sub-100ms response times for metrics
- **Reliability**: No crashes or panics in test scenarios
- **Usability**: Clear error messages and helpful output
## Test Scenarios
### Interactive Mode Testing
1. **Dashboard Mode**: Real-time build visualization
2. **Monitor Mode**: Live performance monitoring
3. **Profile Mode**: Performance reporting
4. **Help System**: Command documentation
5. **Error Handling**: Invalid inputs and edge cases
### Project Integration Testing
1. **Maven Projects**: Full integration with Maven build system
2. **Gradle Projects**: Full integration with Gradle build system
3. **Mixed Projects**: Multi-module and complex projects
4. **Large Projects**: Performance with many files
5. **Error Projects**: Build failure scenarios
### Performance Testing
1. **Metrics Collection**: Fast metrics updates
2. **Display Performance**: Smooth dashboard updates
3. **Memory Usage**: Efficient memory tracking
4. **CPU Tracking**: Accurate CPU usage monitoring
5. **Throughput**: High-frequency updates
## Troubleshooting
### Common Issues
1. **Build Failures**: Run `cargo build --bin jbuild` first
2. **Timeouts**: Increase test timeout in script
3. **Missing Files**: Check project structure creation
4. **Permission Issues**: Check directory permissions
5. **Environment**: Ensure proper Java and tool setup
### Debug Commands
```bash
# Check binary exists
ls -la target/debug/jbuild
# Check dependencies
cargo tree
# Check build
cargo check --bin jbuild
# Run single test
cargo test test_name -- --nocapture
```
## Continuous Integration
### Test Automation
- All tests are designed for automated CI/CD
- Test results can be parsed by CI systems
- Performance benchmarks can be tracked over time
- Regression testing prevents feature regressions
### CI Integration
```yaml
# Example GitHub Actions
- name: Run interactive tests
run: |
./test_interactive.sh
- name: Run performance tests
run: |
cargo test interactive_performance_tests -- --nocapture
```
## Future Enhancements
### Planned Test Improvements
1. **More Project Types**: Add more build system support
2. **Stress Testing**: Larger scale performance tests
3. **Cross-Platform**: Test on different operating systems
4. **Integration Testing**: Integration with IDE and CI tools
5. **Security Testing**: Test security and permission scenarios
### Test Expansion
1. **Plugin Testing**: Test with Maven and Gradle plugins
2. **Multi-Module**: Test complex multi-module projects
3. **Remote Builds**: Test with remote repositories
4. **Network Scenarios**: Test network-related functionality
5. **User Experience**: Test usability and accessibility
This comprehensive test suite ensures that all new interactive capabilities are thoroughly validated and work correctly in various scenarios.