QtTest: moc file will be not generated
c++, qt
Solution
I had a similar problem on Linux. The included moc file was not regenerated and therefore was not matching the test cases. The reason is that I was mixing shadow build and in-source build, and the included moc in the shadow build was actually the stalled one from the in-source build.
The solution in this situation is to remove the moc file from the in-source build, then force rebuild (clean then build) the test class in the shadow build. It triggers the regeneration of the moc file and all tests run normaly after that.
Problem
I am trying to build a simple unittest with QTTest. The file MyTest.cpp looks like: ``` #include <QtTest/QtTest> class MyTest : public QObject { Q_OBJECT private slots: void test() { QVERIFY( true ); } }; QTEST_MAIN( MyTest ) #include "mytest.moc" ``` Now I have create a simple pro-file to generate the executable. But while building it the compiler cannot find the created file mytest.moc, because it wasn's created. When I cann the moc-compiler manually everything worked fine. The pro-file looks like: ``` QT +=testlib TEMPLATE = app TARGET = unittests INCLUDEPATH += . # Input SOURCES += MyTest.cpp ``` Does anyone have an idea, what I have missed? I am using VS2010, QT5.1 and Windows7. Thanks in advance, Kim