Discussion:
[Interest] Failing to use QUICK_TEST_MAIN_WITH_SETUP
Marc Van Daele
2018-10-24 08:57:37 UTC
Permalink
I'm trying to get an answer to
https://forum.qt.io/topic/95715/qtest-failing-to-use-quick_test_main_with_setup
(I hope it is not considered impolite to re-post it here )

Basically I'm looking for a minimal but complete stand-alone example using
the new QUICK_TEST_MAIN_WITH_SETUP macro.
I'm using Qt 5.11.2

Thanks in advance,

Marc
Mitch Curtis
2018-10-24 09:10:14 UTC
Permalink
-----Original Message-----
Behalf Of Marc Van Daele
Sent: Wednesday, 24 October 2018 10:58 AM
Subject: [Interest] Failing to use QUICK_TEST_MAIN_WITH_SETUP
I'm trying to get an answer to https://forum.qt.io/topic/95715/qtest-failing-
to-use-quick_test_main_with_setup
(I hope it is not considered impolite to re-post it here )
Basically I'm looking for a minimal but complete stand-alone example using
the new QUICK_TEST_MAIN_WITH_SETUP macro.
I'm using Qt 5.11.2
Thanks in advance,
Marc
Hi Marc.

The #include "tst_mytest.moc" is probably what's missing, as without that the QMetaObject::invokeMethod() call will fail. You should change the include to match the cpp file that the Setup type is in. For example, if your .cpp file is Setup.cpp:

#include "Setup.moc"

Sorry that the documentation is lacking here - it really should explain what to name that include. I'll submit a patch for it.
Marc Van Daele
2018-10-24 09:42:49 UTC
Permalink
Thanks!
Adding #include "main.moc" indeed worked!

I also tried to put Setup.h/cpp in a separate class (and no #include of the
moc) but I couldn't get that one working.
Note also that the example on
https://doc.qt.io/qt-5.11/qtquicktest-index.html#executing-c-before-qml-tests
is missing a Q_OBJECT!

Kind Regards,

Marc
Post by Marc Van Daele
-----Original Message-----
Behalf Of Marc Van Daele
Sent: Wednesday, 24 October 2018 10:58 AM
Subject: [Interest] Failing to use QUICK_TEST_MAIN_WITH_SETUP
I'm trying to get an answer to
https://forum.qt.io/topic/95715/qtest-failing-
to-use-quick_test_main_with_setup
(I hope it is not considered impolite to re-post it here )
Basically I'm looking for a minimal but complete stand-alone example
using
the new QUICK_TEST_MAIN_WITH_SETUP macro.
I'm using Qt 5.11.2
Thanks in advance,
Marc
Hi Marc.
The #include "tst_mytest.moc" is probably what's missing, as without that
the QMetaObject::invokeMethod() call will fail. You should change the
include to match the cpp file that the Setup type is in. For example, if
#include "Setup.moc"
Sorry that the documentation is lacking here - it really should explain
what to name that include. I'll submit a patch for it.
Mitch Curtis
2018-10-24 10:14:55 UTC
Permalink
-----Original Message-----
Sent: Wednesday, 24 October 2018 11:43 AM
Subject: Re: [Interest] Failing to use QUICK_TEST_MAIN_WITH_SETUP
Thanks!
Adding #include "main.moc" indeed worked!
I also tried to put Setup.h/cpp in a separate class (and no #include of the
moc) but I couldn't get that one working.
Hmm, I'm not sure why that doesn't work - it should work the same as regular moc'd classes/files. Though it's worth mentioning that I've never seen an auto test (class) that wasn't solely contained within a .cpp file.
Note also that the example on https://doc.qt.io/qt-5.11/qtquicktest-
index.html#executing-c-before-qml-tests is missing a Q_OBJECT!
Nicely spotted, will update the patch. :)
Kind Regards,
Marc
-----Original Message-----
Behalf Of Marc Van Daele
Sent: Wednesday, 24 October 2018 10:58 AM
Subject: [Interest] Failing to use QUICK_TEST_MAIN_WITH_SETUP
I'm trying to get an answer to
https://forum.qt.io/topic/95715/qtest-failing-
to-use-quick_test_main_with_setup
(I hope it is not considered impolite to re-post it here )
Basically I'm looking for a minimal but complete stand-alone
example using
the new QUICK_TEST_MAIN_WITH_SETUP macro.
I'm using Qt 5.11.2
Thanks in advance,
Marc
Hi Marc.
The #include "tst_mytest.moc" is probably what's missing, as without
that the QMetaObject::invokeMethod() call will fail. You should change the
include to match the cpp file that the Setup type is in. For example, if your
#include "Setup.moc"
Sorry that the documentation is lacking here - it really should explain
what to name that include. I'll submit a patch for it.
Loading...