|
| 1 | +# ProgramVer Test Suite |
| 2 | + |
| 3 | +This directory contains the comprehensive test suite for ProgramVer. |
| 4 | + |
| 5 | +## Running Tests |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +Install the required testing dependencies: |
| 10 | + |
| 11 | +```bash |
| 12 | +pip install -r requirements.txt |
| 13 | +``` |
| 14 | + |
| 15 | +On Linux systems, you'll also need to install tkinter and xvfb for headless GUI testing: |
| 16 | + |
| 17 | +```bash |
| 18 | +sudo apt-get install python3-tk xvfb |
| 19 | +``` |
| 20 | + |
| 21 | +### Running All Tests |
| 22 | + |
| 23 | +To run all tests: |
| 24 | + |
| 25 | +```bash |
| 26 | +# On Linux (headless environment) |
| 27 | +xvfb-run -a python -m pytest tests/ -v |
| 28 | + |
| 29 | +# On Windows/macOS (with display) |
| 30 | +python -m pytest tests/ -v |
| 31 | +``` |
| 32 | + |
| 33 | +### Running Tests with Coverage |
| 34 | + |
| 35 | +To run tests with coverage report: |
| 36 | + |
| 37 | +```bash |
| 38 | +# On Linux |
| 39 | +xvfb-run -a python -m pytest tests/ --cov=. --cov-report=term-missing --cov-report=html |
| 40 | + |
| 41 | +# On Windows/macOS |
| 42 | +python -m pytest tests/ --cov=. --cov-report=term-missing --cov-report=html |
| 43 | +``` |
| 44 | + |
| 45 | +The HTML coverage report will be generated in the `htmlcov` directory. |
| 46 | + |
| 47 | +### Running Specific Tests |
| 48 | + |
| 49 | +To run a specific test file: |
| 50 | + |
| 51 | +```bash |
| 52 | +xvfb-run -a python -m pytest tests/test_main.py -v |
| 53 | +``` |
| 54 | + |
| 55 | +To run a specific test class: |
| 56 | + |
| 57 | +```bash |
| 58 | +xvfb-run -a python -m pytest tests/test_main.py::TestOpenLicense -v |
| 59 | +``` |
| 60 | + |
| 61 | +To run a specific test method: |
| 62 | + |
| 63 | +```bash |
| 64 | +xvfb-run -a python -m pytest tests/test_main.py::TestOpenLicense::test_openLicense_creates_window -v |
| 65 | +``` |
| 66 | + |
| 67 | +## Test Structure |
| 68 | + |
| 69 | +The test suite is organized as follows: |
| 70 | + |
| 71 | +- `test_main.py` - Tests for the main ProgramVer module |
| 72 | + - `TestOpenLicense` - Tests for the openLicense function |
| 73 | + - `TestOpenEULA` - Tests for the openEULA function |
| 74 | + - `TestProgramVer` - Tests for the ProgramVer main function |
| 75 | + - `TestModuleIntegration` - Integration tests for the module |
| 76 | + |
| 77 | +## GitHub Actions Integration |
| 78 | + |
| 79 | +The test suite is automatically run on GitHub Actions for every push and pull request. The workflow: |
| 80 | + |
| 81 | +- Runs on Ubuntu, Windows, and macOS |
| 82 | +- Tests against Python 3.9, 3.10, 3.11, and 3.12 |
| 83 | +- Generates coverage reports |
| 84 | +- Uploads coverage to Codecov (for master branch) |
| 85 | + |
| 86 | +See `.github/workflows/tests.yml` for the complete configuration. |
| 87 | + |
| 88 | +## Writing New Tests |
| 89 | + |
| 90 | +When adding new features to ProgramVer, please add corresponding tests following these guidelines: |
| 91 | + |
| 92 | +1. Create test classes that inherit from `unittest.TestCase` |
| 93 | +2. Use descriptive test method names that start with `test_` |
| 94 | +3. Use mocking for GUI components to avoid requiring a display |
| 95 | +4. Add docstrings to explain what each test verifies |
| 96 | +5. Ensure tests are independent and can run in any order |
| 97 | + |
| 98 | +## Coverage Goals |
| 99 | + |
| 100 | +We aim to maintain at least 90% code coverage for the main module. Currently, we have 100% coverage for `main.py`. |
0 commit comments