Где именно мне поставить QTEST_MAIN? ⇐ C++
-
Anonymous
Где именно мне поставить QTEST_MAIN?
I wanted to add some unit tests to an existent Qt application, but I can't figure out how to do it.
The official documentation explains it, telling that I need to create a class containing the test code (I suppose that both the class itself and its implementation belong to the same file?) Then, the documentation states:
Finally, to make our test case a stand-alone executable, the following two lines are needed:
QTEST_MAIN(TestQString) #include "testqstring.moc" Do I have to add it in the same file which contains the test code? Or do I have to create some other file? Or maybe I am supposed to put it in the exising main.cpp?
Another official documentation seems even more cryptic regarding QTEST_MAIN:
Finally, if the test class has a static public void initMain() method, it is called by the QTEST_MAIN macros before the QApplication object is instantiated. This was added in 5.14.
In their example, however, there is no initMain method. Do I need to add one? And, anyway, what should I do with the actual QTEST_MAIN macro?
Источник: https://stackoverflow.com/questions/780 ... qtest-main
I wanted to add some unit tests to an existent Qt application, but I can't figure out how to do it.
The official documentation explains it, telling that I need to create a class containing the test code (I suppose that both the class itself and its implementation belong to the same file?) Then, the documentation states:
Finally, to make our test case a stand-alone executable, the following two lines are needed:
QTEST_MAIN(TestQString) #include "testqstring.moc" Do I have to add it in the same file which contains the test code? Or do I have to create some other file? Or maybe I am supposed to put it in the exising main.cpp?
Another official documentation seems even more cryptic regarding QTEST_MAIN:
Finally, if the test class has a static public void initMain() method, it is called by the QTEST_MAIN macros before the QApplication object is instantiated. This was added in 5.14.
In their example, however, there is no initMain method. Do I need to add one? And, anyway, what should I do with the actual QTEST_MAIN macro?
Источник: https://stackoverflow.com/questions/780 ... qtest-main
Мобильная версия