Testing Plugin
Overview
The Testing Plugin provides comprehensive guidance for the VMPilot testing ecosystem, including unit tests, end-to-end tests, and code coverage analysis. Testing is an integral part of the VMPilot development workflow and CI/CD pipeline, not just an optional activity.
Testing Types
VMPilot employs multiple testing approaches:
- Unit Tests: Test individual components in isolation using pytest
- End-to-End Tests: Test complete workflows using shell scripts and LLM-based evaluation
- Coverage Analysis: Combines results from both test types to ensure comprehensive testing
Key Features
- Comprehensive Testing Framework: Supports both unit and end-to-end testing approaches
- CI/CD Integration: Testing is integrated into the development workflow and enforced in the CI/CD pipeline
- Coverage Analysis: Built-in tools to measure and improve test coverage
- Best Practices: Recommendations for test isolation, coverage, readability, and maintenance
- Test Templates: Ready-to-use templates for both unit and end-to-end tests
Testing as Part of Development Workflow
Testing is not an optional activity but a required part of the development process:
- Feature Development: Tests must be created alongside any new feature implementation
- Pre-Merge Validation: Coverage analysis must be run before merging code
- CI/CD Enforcement: The CI/CD pipeline validates test coverage thresholds
Unit Testing
Unit tests focus on testing individual components in isolation:
- Test files are named with
test_
prefix - Test functions also use the
test_
prefix - Related tests are grouped into classes with
Test
prefix - Tests use pytest fixtures for setup and teardown
- External dependencies are mocked
Running Unit Tests
Bash | |
---|---|
Running Tests with Coverage
Bash | |
---|---|
End-to-End Testing
End-to-end tests validate complete workflows from the user's perspective:
- Tests are implemented as shell scripts in the
tests/scripts/
directory - Tests use the
TEST_DIR
environment variable for isolation - Tests run CLI commands with temperature 0 for consistent results
- Tests validate outputs using both exact matching and LLM-based evaluation
Running End-to-End Tests
Bash | |
---|---|
Coverage Analysis
The project targets a minimum of 70% code coverage. Coverage analysis helps identify untested code:
Bash | |
---|---|
Unit Test Example
Here's an example of a unit test for the CLI module:
End-to-End Test Example
Here's an example of an end-to-end test script:
Benefits of Testing Integration
- Comprehensive Quality Assurance: Combines unit and end-to-end testing approaches
- CI/CD Integration: Tests are automatically run as part of the development pipeline
- Coverage Requirements: Enforces minimum test coverage thresholds
- Standardized Process: Ensures all features have adequate test coverage
- Continuous Improvement: Regular coverage analysis identifies testing gaps