TextWave includes a comprehensive test suite with unit tests, integration tests, and GUI tests covering all major functionality.
-
PDF Extraction (
test_pdf_extraction.py)- Text extraction from valid PDFs
- Page number removal
- Page count accuracy
- Error handling
-
Version Checking (
test_version_checking.py)- edge-tts update detection
- PyPI API integration
- Network error handling
- Version comparison logic
-
App Updates (
test_app_updates.py)- GitHub release checking
- Version tag parsing
- DMG asset detection
- API error handling
-
GUI Components (
test_gui_components.py)- Window initialization
- Button state management
- Banner creation and dismissal
- Resource path resolution
-
Integration Tests (
test_integration.py)- Sleep prevention (caffeinate)
- Thread lifecycle management
- Signal emission
- Error recovery
python3 -m pip install -r requirements-test.txtpython3 -m pytest# Unit tests only
python3 -m pytest -m unit
# Integration tests only
python3 -m pytest -m integration
# GUI tests only
python3 -m pytest -m gui
# Specific test file
python3 -m pytest tests/test_pdf_extraction.py -v# Terminal report
python3 -m pytest --cov=pdf2mp3_gui --cov-report=term-missing
# HTML report (opens in browser)
python3 -m pytest --cov=pdf2mp3_gui --cov-report=html
open htmlcov/index.htmlTrigger: Every pull request to main branch
Steps:
- Checkout code
- Set up Python 3.11
- Install dependencies
- Run linting (flake8)
- Run test suite with coverage
- Upload coverage to Codecov
- Test app builds successfully
Location: .github/workflows/pr-tests.yml
Trigger: Push to main branch (excludes markdown and docs)
Steps:
- Extract version from
__version__in code - Check if version tag already exists
- If new version:
- Build macOS .app bundle
- Create DMG installer
- Create .app.zip for direct download
- Create GitHub release with assets
- Auto-tag with version number
Location: .github/workflows/release.yml
-
Update version in
pdf2mp3_gui.py:__version__ = "1.0.1" # Increment version
-
Commit and push to main:
git add pdf2mp3_gui.py git commit -m "Bump version to 1.0.1" git push origin main -
GitHub Actions automatically:
- Builds the app
- Creates DMG
- Creates release with tag
v1.0.1 - Attaches both DMG and .app.zip
# Build app
.github/scripts/build-app.sh
# Create DMG
.github/scripts/create-dmg.sh 1.0.0
# Result:
# - dist/TextWave.app
# - dist/TextWave.app.zip
# - TextWave-1.0.0.dmg- Cleans previous builds
- Runs
python setup.py py2app - Creates .app.zip for distribution
- Verifies build succeeded
- Uses
create-dmgif available (better UI) - Falls back to
hdiutil(macOS built-in) - Creates professional installer DMG
- Includes Applications folder shortcut
- Mock External Calls: All network requests and subprocess calls should be mocked
- Use Fixtures: Leverage pytest fixtures for common setup (sample PDFs, QApplication)
- Test Isolation: Each test should be independent
- Signal Testing: Use
qtbot.waitSignal()for Qt thread testing - Coverage Goals: Aim for 80%+ coverage on core functionality
- Platform: macOS-latest
- Python: 3.11
- Test Duration: ~3-5 minutes
- Build Duration: ~5-10 minutes
Coverage reports are automatically uploaded to Codecov (if configured) and can be viewed:
- In PR comments
- On Codecov dashboard
- In local HTML reports
# Ensure dependencies are installed
python3 -m pip install -r requirements-test.txt
# Clear pytest cache
python3 -m pytest --cache-clear
# Run with verbose output
python3 -m pytest -vv- Check GitHub Actions logs
- Verify version is properly incremented
- Ensure all tests pass locally first
- Check that scripts are executable
- GitHub runners may not have
create-dmginstalled - Workflow falls back to
hdiutilautomatically - Both methods produce valid DMGs
- Add performance benchmarks
- Add screenshot tests
- Add accessibility tests
- Expand edge case coverage
- Add mutation testing