I need to create Unit-Test.
But first I have to figure out what to do. The QtQuick2 application is written, and now I would like to run Unit-Tests with a graphical interface. What are the steps for Unit-Tests with a GUI? After reading the Qt documents, I could not create any ideas for starting the test.
Hope someone can help me.
Change I managed to run several tests after adding tst_button.qml and tst_test.cpp to my project (now there are comments in main.cpp). Is this correct, or should I create a new project just for tests? If so, which project is needed? And the last question: do I need to create my MainForm for button clicks, for example?
tst_button.qml
import QtQuick 2.4 import QtTest 1.0 Rectangle{ id: myRec property var myMainForm: null TestCase{ name:"ButtonClick" when:windowShown function test_init(){ var createMyWindow = "import QtQuick 2.0; MainForm{id:myForm}" var myMainForm = Qt.createQmlObject(createMyWindow,myRec) myRec.myMainForm = myMainForm } } }
tst_test.cpp
#include <QtQuickTest/quicktest.h> QUICK_TEST_MAIN(test)
source share