This document outlines the comprehensive testing infrastructure updates made to the QtMeshEditor project's GitHub Actions CI/CD pipeline. The implementation ensures that the new MaterialEditorQML unit tests are properly executed and their coverage is accurately reported to both SonarQube and CodeClimate.
Windows Unit Tests (unit-tests-windows)
- Runs comprehensive MaterialEditorQML tests on Windows platform
- Uses MinGW compiler with Qt 6.9.1
- Executes all test categories: unit, QML integration, performance, and component tests
- Uploads test results as artifacts for analysis
Enhanced Linux Unit Tests (unit-tests-linux)
- Updated to run comprehensive test suite with proper coverage collection
- Integrated with SonarQube and CodeClimate reporting
- Uses gcov/lcov for coverage data generation
- Supports X11 virtual display for QML tests
-
Multi-Platform Testing: Tests now run on both Windows and Linux
-
Comprehensive Test Execution: All test categories are executed:
MaterialEditorQML_test(C++ unit tests)MaterialEditorQML_qml_test(QML integration tests)MaterialEditorQML_perf_test(Performance tests)MaterialEditorQML_qml_test_runner(QML component tests)
-
Enhanced Coverage Collection:
- Proper gcov flags for C++ coverage:
--coverage -fprofile-arcs -ftest-coverage - Improved gcovr configuration with exclusions for test files
- Better lcov filtering for CodeClimate integration
- Proper gcov flags for C++ coverage:
-
Test Result Artifacts:
- XML test results uploaded for all platforms
- Coverage reports in multiple formats (XML, HTML, LCOV)
- Separate artifacts for Windows and Linux test results
# Main source directories
sonar.sources=src/
sonar.tests=src/,tests/
# Test file patterns - include all our new test files
sonar.test.inclusions=**/*_test.cpp,**/test_*.cpp,tests/**/*.cpp,tests/**/*.qml
# Enhanced exclusions
sonar.exclusions=**/OgreXML/**,**/dependencies/**,**/*_autogen/**,**/CMakeFiles/**,**/ui_files/**,**/moc_*,**/_deps/**
# Coverage exclusions - exclude test files from coverage calculation
sonar.coverage.exclusions=**/*_test.cpp,**/test_*.cpp,tests/**/*.cpp,tests/**/*.qml,**/*_autogen/**
# C++ specific optimizations
sonar.cfamily.compile-commands=compile_commands.json
sonar.cfamily.cache.enabled=true
sonar.cfamily.threads=4- Proper test file classification for better analysis
- Enhanced exclusion patterns to focus on production code
- Optimized C++ analysis settings for performance
- Better separation of source and test code
exclude_patterns:
# ... existing patterns ...
# Exclude all test files from code quality analysis
- "**/*_test.cpp"
- "**/test_*.cpp"
- "tests/**/*.cpp"
- "tests/**/*.qml"
- "tests/**/*.h"
- "**/*_test_runner.cpp"
- "**/*_perf_test.cpp"
- "**/*_qml_test.cpp"
# Test coverage settings
prepare:
fetch:
- url: https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
path: ./cc-test-reporter- Test files excluded from maintainability analysis
- Focus on production code quality metrics
- Proper test reporter integration
# Helper function to create test executables
function(create_test_executable target_name source_files link_libraries)
add_executable(${target_name} ${source_files})
target_include_directories(${target_name} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../src
${CMAKE_CURRENT_SOURCE_DIR}/../ui_files
)
target_link_libraries(${target_name} ${link_libraries})
# Add the test to CTest
add_test(NAME ${target_name} COMMAND ${target_name})
endfunction()MaterialEditorQML_test- C++ unit testsMaterialEditorQML_qml_test- QML integration testsMaterialEditorQML_perf_test- Performance testsMaterialEditorQML_qml_test_runner- QML component tests
- Automatic Google Test discovery for detailed reporting
- Proper library linking including Ogre3D and Assimp
- CTest integration for CI execution
- QML test file deployment to runtime directories
- Build Phase: Configure with coverage flags, build all test executables
- Test Execution: Run comprehensive test suite with XML output
- Coverage Generation:
- Generate gcov files for all object files
- Create gcovr reports (XML, HTML)
- Process lcov data for CodeClimate
- Reporting:
- Upload to SonarQube with proper test/source separation
- Submit coverage to CodeClimate
- Archive test results and coverage reports
- Build Phase: Configure and build test executables
- Dependency Setup: Copy required DLLs for test execution
- Test Execution: Run all test categories with XML output
- Artifact Upload: Store test results for analysis
- All production source files in
src/(excluding test files) - MaterialEditorQML.cpp and related components
- Qt integration code
- Ogre3D integration code
- All
*_test.cppfiles - Test runner and performance test files
- Auto-generated MOC files
- Dependencies (OgreXML, ogre-procedural)
- CMake generated files
- Test Coverage: Tracked for production code only
- Code Quality: Maintainability, reliability, security analysis
- Test Detection: Proper identification of test vs. source files
- Performance: Optimized analysis with caching and threading
- Maintainability: Focus on production code complexity
- Test Coverage: Accurate coverage reporting via lcov
- Duplication: Detection excluding test code patterns
mkdir build
cmake -S . -B build -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
cmake --build build
ctest --test-dir build --verbose# With coverage flags
cmake -S . -B build -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="--coverage"
cmake --build build
ctest --test-dir build
gcovr --root . --html --html-details -o coverage.html- Pull Requests: Full test suite runs on Linux and Windows
- Master Branch: Complete pipeline with coverage reporting
- Releases: All platforms including macOS
- Comprehensive Coverage: 50+ individual test cases across multiple categories
- Cross-Platform Validation: Tests run on Windows and Linux
- Quality Assurance: Integrated SonarQube and CodeClimate reporting
- Performance Monitoring: Dedicated performance test suite
- Regression Detection: Automated test execution on every change
- Documentation: Clear separation of test and production code
- Maintainability: Organized test structure with helper functions
- QML Test Failures: Ensure X11 virtual display is properly configured
- Coverage Gaps: Verify gcov flags are applied to all source files
- Missing Dependencies: Check that all required Qt modules are linked
- Test Discovery: Confirm Google Test executables are properly built
# Check test executables
ls -la build/bin/*test*
# Verify coverage files
find build -name "*.gcno" -o -name "*.gcda"
# Test individual components
./build/bin/MaterialEditorQML_test --gtest_list_testsThis implementation provides a robust, scalable testing infrastructure that ensures code quality while supporting the comprehensive MaterialEditorQML test suite.