# QML unit tests — opt-in, only built when BUILD_TESTING is on (CTest's # convention). Wired from ../CMakeLists.txt under the same guard. # # Run via: # cmake -S . -B build -DBUILD_TESTING=ON # cmake --build build --target qml_unit_tests # ctest --test-dir build --output-on-failure -R qml_unit_tests # # Or from the skeleton / example Makefiles via `make qmltest`. find_package(Qt6 6.5 REQUIRED COMPONENTS QuickTest Network) # A tiny PhpQml.Bridge.Tests QML module that exposes the in-process # stub HTTP server used by tst_reactive_list_model.qml. Static so it # links into the test exe alongside the production bridge module. qt_add_qml_module(php_qml_bridge_tests URI PhpQml.Bridge.Tests VERSION 1.0 STATIC OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/PhpQml/Bridge/Tests SOURCES TestHttpServer.h TestHttpServer.cpp ) target_link_libraries(php_qml_bridge_tests PUBLIC Qt6::Core Qt6::Network Qt6::Qml ) qt_add_executable(qml_unit_tests main.cpp) target_link_libraries(qml_unit_tests PRIVATE Qt6::QuickTest Qt6::Qml Qt6::Quick php_qml_bridge # production module — type implementations php_qml_bridgeplugin # …and its auto-generated QQmlEngineExtensionPlugin php_qml_bridge_tests # in-process HTTP stub php_qml_bridge_testsplugin # …and its plugin ) # QUICK_TEST_MAIN reads QUICK_TEST_SOURCE_DIR from the macro definition # at compile time. Point it at this directory so qmltestrunner finds # the tst_*.qml files regardless of where the binary runs. target_compile_definitions(qml_unit_tests PRIVATE QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" ) add_test(NAME qml_unit_tests COMMAND qml_unit_tests)