Getting the Qt Creator test scanner to find all test classes in one project
-
Our team uses Qt Creator. We have quite large projects, and for each project we have a test project with a test class for every production class. The main of the test project calls
QTest::qExec
for every test class. We run our tests by simply running the test project.That works fine, but the output is limited to the console, looking like this:
********* Start testing of TestClass1 ********* Config: Using QtTest library 5.10.1, Qt 5.10.1 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 7.3.0) PASS : TestClass1::initTestCase() PASS : TestClass1::test1() PASS : TestClass1::test2() PASS : TestClass1::cleanupTestCase() Totals: 2 passed, 0 failed, 0 skipped, 0 blacklisted, 3ms ********* Finished testing of TestClass1********* ********* Start testing of TestClass2 ********* Config: Using QtTest library 5.10.1, Qt 5.10.1 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 7.3.0) PASS : TestClass2::initTestCase() PASS : TestClass2::test1() PASS : TestClass2::test2() PASS : TestClass2::cleanupTestCase() Totals: 2 passed, 0 failed, 0 skipped, 0 blacklisted, 3ms ********* Finished testing of TestClass2*********
I just discovered the integrated test gui and would really like to use it. However, I can't get the scanner (Tools->Tests->Rescan tests) to find all tests in a project. If I write this in the main it works fine for TestClass1:
int main(int argc, char** argv) { TestClass1 test; return QTest::qExec(&test, argc, argv); }
However, if I try to add TestClass2 as below the scanner only recognizes TestClass2:
int main(int argc, char** argv) { TestClass1 test1; int ret = QTest::qExec(&test1, argc, argv); TestClass2 test2; int ret &= QTest::qExec(&test2, argc, argv); return ret; }
It seem as if the scanner only finds the last class executed with
QTest::qExec
.Any idea how I could get it to find all tests, without touching the existing test classes?