This directory contains the comprehensive test suite for ProgramVer.
Install the required testing dependencies:
pip install -r requirements.txtOn Linux systems, you'll also need to install tkinter and xvfb for headless GUI testing:
sudo apt-get install python3-tk xvfbTo run all tests:
# On Linux (headless environment)
xvfb-run -a python -m pytest tests/ -v
# On Windows/macOS (with display)
python -m pytest tests/ -vTo run tests with coverage report:
# On Linux
xvfb-run -a python -m pytest tests/ --cov=. --cov-report=term-missing --cov-report=html
# On Windows/macOS
python -m pytest tests/ --cov=. --cov-report=term-missing --cov-report=htmlThe HTML coverage report will be generated in the htmlcov directory.
To run a specific test file:
xvfb-run -a python -m pytest tests/test_main.py -vTo run a specific test class:
xvfb-run -a python -m pytest tests/test_main.py::TestOpenLicense -vTo run a specific test method:
xvfb-run -a python -m pytest tests/test_main.py::TestOpenLicense::test_openLicense_creates_window -vThe test suite is organized as follows:
test_main.py- Tests for the main ProgramVer moduleTestOpenLicense- Tests for the openLicense functionTestOpenEULA- Tests for the openEULA functionTestProgramVer- Tests for the ProgramVer main functionTestModuleIntegration- Integration tests for the module
The test suite is automatically run on GitHub Actions for every push and pull request. The workflow:
- Runs on Ubuntu, Windows, and macOS
- Tests against Python 3.9, 3.10, 3.11, and 3.12
- Generates coverage reports
- Uploads coverage to Codecov (for master branch)
See .github/workflows/tests.yml for the complete configuration.
When adding new features to ProgramVer, please add corresponding tests following these guidelines:
- Create test classes that inherit from
unittest.TestCase - Use descriptive test method names that start with
test_ - Use mocking for GUI components to avoid requiring a display
- Add docstrings to explain what each test verifies
- Ensure tests are independent and can run in any order
We aim to maintain at least 90% code coverage for the main module. Currently, we have 100% coverage for main.py.