This directory contains UI tests for the Conference Registration application using the Qt Test framework.
The UI tests validate the graphical user interface components to ensure:
- Widgets are properly initialized
- User interactions work correctly
- Dialogs display and collect data appropriately
- UI elements are properly connected via signals and slots
Tests for the main application window:
- Window initialization and default state
- Menu bar and menu items (File, Edit, Reports, Help)
- Toolbar existence and functionality
- Registration table view and model
- Search functionality via line edit widget
Tests for the new registration dialog:
- Dialog initialization
- Form field existence (name, email, affiliation, date)
- Registration type combo box and switching
- Conditional field visibility (student qualification, guest category)
- Button functionality (Register, Cancel)
- Dialog acceptance and rejection
Tests for statistics dialogs:
TotalFeesDialog:
- Dialog initialization
- Registration type combo box
- Total fees display field
- Calculation updates when registration type changes
TotalRegisteredDialog:
- Dialog initialization
- Affiliation input field
- Total count display field
- Dynamic count updates based on affiliation
- Qt 5 or Qt 6 with Qt Test module
- CMake 3.5 or higher
- C++17 compatible compiler
cd build
export QT_QPA_PLATFORM=offscreen
ctest --output-on-failure -R "MainWindowTests|NewRegistrationDialogTests|StatisticsDialogsTests"cd build/tests/ui
export QT_QPA_PLATFORM=offscreen
# Run all UI tests
./mainwindow_test
./newregistrationdialog_test
./statistics_dialogs_testcd build
export QT_QPA_PLATFORM=offscreen
ctest --output-on-failure -R "MainWindowTests|NewRegistrationDialogTests|StatisticsDialogsTests"cd build/tests/ui
export QT_QPA_PLATFORM=offscreen
# List all test functions in a specific test binary
./mainwindow_test -functions
# Run a specific test function
./mainwindow_test MainWindowTest::testWindowInitializationUI tests use Qt's built-in testing framework (QTest) which provides:
- Test fixtures with
init()andcleanup()methods - Assertion macros (
QVERIFY,QCOMPARE) - Widget interaction simulation (
QTest::mouseClick,QTest::keyClick) - Automatic test discovery via
QTEST_MAINmacro
Tests run in headless mode using Qt's offscreen platform plugin:
- No display required
- Suitable for CI/CD pipelines
- Fast execution
- Full widget functionality without rendering
- Existence Tests: Verify widgets are created and accessible
- State Tests: Check initial states and default values
- Interaction Tests: Simulate user actions (clicks, text input)
- Integration Tests: Verify widget connections and signal/slot behavior
- Tests focus on widget structure and basic interactions
- Complex user workflows are better suited for integration tests
- Visual appearance and rendering are not validated
- Some modal dialog behaviors are difficult to test automatically
These UI tests complement the existing test suite:
- Unit Tests (42): Core business logic
- Integration Tests (16): XML persistence
- UI Tests (30+): User interface components
Together, these provide comprehensive coverage of the application.
UI tests run automatically in CI via GitHub Actions:
- name: Run tests
run: |
cd build
export QT_QPA_PLATFORM=offscreen
ctest --output-on-failureThe QT_QPA_PLATFORM=offscreen environment variable enables headless testing.
Potential improvements for UI testing:
- Add tests for keyboard navigation
- Test context menu actions
- Add tests for edit/delete functionality
- Test file dialog interactions (mocked)
- Add screenshot comparison tests
- Test responsive behavior with different window sizes
- Add accessibility tests (keyboard-only navigation)
When adding new UI components:
- Create corresponding test file in
tests/ui/ - Follow existing naming conventions
- Test widget existence, state, and basic interactions
- Update this README with new test descriptions
- Ensure tests run headless for CI compatibility