|
| 1 | +# PyAvatar Test Suite |
| 2 | + |
| 3 | +This document describes the comprehensive test suite for the PyAvatar project. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The test suite provides comprehensive coverage of the PyAvatar codebase with 23 tests achieving 86% code coverage. |
| 8 | + |
| 9 | +## Test Structure |
| 10 | + |
| 11 | +The test suite is organized into the following test modules: |
| 12 | + |
| 13 | +### `tests/test_avatars.py` |
| 14 | +Tests for the main avatars functionality: |
| 15 | +- Window creation and initialization |
| 16 | +- Title label creation |
| 17 | +- Account frame creation |
| 18 | +- Link/webbrowser functionality |
| 19 | +- Global variable initialization |
| 20 | + |
| 21 | +### `tests/test_images.py` |
| 22 | +Tests for the `PyAvatar/images.py` module: |
| 23 | +- Module import validation |
| 24 | +- Documentation verification |
| 25 | + |
| 26 | +### `tests/test_links.py` |
| 27 | +Tests for the `PyAvatar/links.py` module: |
| 28 | +- Module import validation |
| 29 | +- Documentation verification |
| 30 | + |
| 31 | +### `tests/test_integration.py` |
| 32 | +Integration tests for the full application: |
| 33 | +- Main module imports |
| 34 | +- Avatars function existence |
| 35 | +- Application initialization |
| 36 | +- Package structure validation |
| 37 | +- PyAvatar package imports |
| 38 | + |
| 39 | +### `tests/test_main_pytest.py` |
| 40 | +Pytest-style tests for main.py: |
| 41 | +- Window creation |
| 42 | +- Mainloop execution |
| 43 | +- Variable existence checks |
| 44 | +- Function callability |
| 45 | +- Webbrowser integration |
| 46 | +- Module structure |
| 47 | + |
| 48 | +### `tests/conftest.py` |
| 49 | +Pytest configuration and shared fixtures: |
| 50 | +- Tkinter mocking for headless testing |
| 51 | +- Shared fixtures for tests |
| 52 | + |
| 53 | +## Running Tests |
| 54 | + |
| 55 | +### Run all tests: |
| 56 | +```bash |
| 57 | +pytest |
| 58 | +``` |
| 59 | + |
| 60 | +### Run with verbose output: |
| 61 | +```bash |
| 62 | +pytest -v |
| 63 | +``` |
| 64 | + |
| 65 | +### Run with coverage: |
| 66 | +```bash |
| 67 | +pytest --cov=. --cov-report=term-missing |
| 68 | +``` |
| 69 | + |
| 70 | +### Run specific test file: |
| 71 | +```bash |
| 72 | +pytest tests/test_avatars.py |
| 73 | +``` |
| 74 | + |
| 75 | +### Run specific test: |
| 76 | +```bash |
| 77 | +pytest tests/test_avatars.py::TestAvatarsFunction::test_avatars_window_creation |
| 78 | +``` |
| 79 | + |
| 80 | +## GitHub Actions Integration |
| 81 | + |
| 82 | +The test suite is integrated with GitHub Actions through `.github/workflows/pytest.yml`: |
| 83 | + |
| 84 | +### Features: |
| 85 | +- **Matrix Testing**: Tests run across multiple Python versions (3.9, 3.10, 3.11, 3.12) |
| 86 | +- **Multi-OS Testing**: Tests run on Ubuntu, Windows, and macOS |
| 87 | +- **Coverage Reporting**: Automatic coverage reports generated |
| 88 | +- **Artifacts**: Coverage reports uploaded as GitHub Actions artifacts |
| 89 | +- **Summary**: Coverage summary displayed in GitHub Actions summary |
| 90 | + |
| 91 | +### Workflow Triggers: |
| 92 | +- Push to any branch |
| 93 | +- Pull requests |
| 94 | + |
| 95 | +## Test Configuration |
| 96 | + |
| 97 | +### `pytest.ini` |
| 98 | +Configuration for pytest: |
| 99 | +- Test discovery patterns |
| 100 | +- Coverage settings |
| 101 | +- Output formatting |
| 102 | +- Test markers |
| 103 | + |
| 104 | +### Test Markers |
| 105 | +- `unit`: Unit tests |
| 106 | +- `integration`: Integration tests |
| 107 | +- `slow`: Slow running tests |
| 108 | + |
| 109 | +## Requirements |
| 110 | + |
| 111 | +Test dependencies are listed in `requirements.txt`: |
| 112 | +- `pytest`: Test framework |
| 113 | +- `pytest-cov`: Coverage plugin |
| 114 | +- `pytest-mock`: Mocking utilities |
| 115 | + |
| 116 | +## Coverage Goals |
| 117 | + |
| 118 | +Current coverage: 86% |
| 119 | + |
| 120 | +Areas with high coverage: |
| 121 | +- main.py: 94% |
| 122 | +- test files: 82-100% |
| 123 | + |
| 124 | +## Notes |
| 125 | + |
| 126 | +- The test suite uses mocked tkinter to allow headless testing (no GUI required) |
| 127 | +- Tests are designed to be fast and not require external dependencies |
| 128 | +- Integration tests validate the full application flow |
| 129 | +- Unit tests focus on individual components |
| 130 | + |
| 131 | +## Contributing |
| 132 | + |
| 133 | +When adding new features: |
| 134 | +1. Write tests for new functionality |
| 135 | +2. Ensure existing tests still pass |
| 136 | +3. Aim to maintain or improve coverage percentage |
| 137 | +4. Follow existing test patterns and naming conventions |
0 commit comments