The QtQuickTest docs don't make it clear how to refer to other components, run tests on them, etc.
It is relatively simple to write a tst_foo.qml, define a GUI object and a TestCase inside it that runs functions called test_* that checks aspects of your GUI object, but that is not a real-world situation. You would have your components to test in files that are not called tst_*. So my questions are:
- The tester automatically runs all QML files called
tst_*.qml. This implies that there are separate qml file with unit tests. But so far, I have only been able to do what this person does: rename the QML object you want to test totst_foo.qmland define aTestCasein it. So the subsequent questions are: - Are you supposed to define a
TestCaseinside the GUI element and call it from atst_foo.qmlfile? If so, how? - Or are you supposed to define a
TestCaseinsidetst_foo.qmlthat refers to your GUI component? If so, how?
Another issue is that the QML loader for the unit test seems to use QQuickView, so it can only load items derived from QQuickItem. So how do you test an ApplicationWindow? In this case, renaming your QML file to tst_mainApp.qml doesn't even work: "QQuickView only supports loading of root objects that derive from QQuickItem."