Testing Qt Quick applications
Qt Quick Test is a framework created for the unit testing of Qt Quick applications. Test cases are written in JavaScript and use the TestCase
QML type. Functions with names beginning with test_
are identified as test cases that need to be executed. The test harness recursively searches for the required source directory for tst_ *.qml
files. You can keep all test .qml
files under one directory and define the QUICK_TEST_SOURCE_DIR
. If it is not defined, then only .qml
files available in the current directory will be included during test execution. Qt doesn't ensure binary compatibility for the Qt Quick Test module. You have to use the appropriate version of the module.
You have to add QUICK_TEST_MAIN()
to the C++ file to begin the execution of the test cases, as shown next:
#include <QtQuickTest> QUICK_TEST_MAIN(testqml)
You need to add the qmltest
module to enable Qt Quick Test. Add the following lines of code to the .pro
file:
QT...