How to run multiple QTest classes? : <p>I have a subproject where I put all my <code>QTest</code> unit tests and build a stand-alone test application that runs the tests (i.e. I run it from within Qt Creator). I have multiple test classes that I can execute with <code>qExec()</code>. However I don't know what is the proper way to execute multiple test classes.</p>

<p>Currently I do it in this way (MVCE):</p>

<h2>tests.pro</h2>

<pre><code>QT -= gui
QT += core \
    testlib

CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
TARGET = testrunner

HEADERS += test_foo.h
SOURCES += main.cpp
</code></pre>

<h2>main.cpp</h2>

<pre><code>#include &lt;QtTest&gt;
#include &lt;QCoreApplication&gt;
#include "test_foo.h"

int main(int argc, char** argv) {
    QCoreApplication app(argc, argv);

    TestFooClass testFoo;
    TestBarClass testBar;
    // NOTE THIS LINE IN PARTICULAR.
    return QTest::qExec(&amp;testFoo, argc, argv) || QTest::qExec(&amp;testBar, argc, argv);
}
</code></pre>

<h2>test_foo.h</h2>

<pre><code>#include &lt;QtTest&gt;

class TestFooClass: public QObject
{
    Q_OBJECT
private slots:
    void test_func_foo() {};
};

class TestBarClass: public QObject
{
    Q_OBJECT
private slots:
    void test_func_bar() {};
};
</code></pre>

<p>However the <a href="http://doc.qt.io/qt-5/qtest.html#qExec" rel="noreferrer">documentation for <code>qExec()</code></a> says this is the wrong way:</p>

<blockquote>
  <p>For stand-alone test applications, this function should not be called more than once, as command-line options for logging test output to files and executing individual test functions will not behave correctly.</p>
</blockquote>

<p>The other major downside is that there is <strong>no single summary for all the test classes</strong>, only for individual classes. This is a problem when I have dozens of classes that each have dozens of tests. To check if all tests passed I have to scroll up to see all the "Totals" of what passed/failed of each class, e.g.:</p>

<pre><code>********* Start testing of TestFooClass *********
PASS   : TestFooClass::initTestCase()
PASS   : TestFooClass::test_func_foo()
PASS   : TestFooClass::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted
********* Finished testing of TestFooClass *********
********* Start testing of TestBarClass *********
PASS   : TestBarClass::initTestCase()
PASS   : TestBarClass::test_func_bar()
PASS   : TestBarClass::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted
********* Finished testing of TestBarClass *********
</code></pre>

<p>I'm also surprised my <code>qExec() || qExec()</code> works considering that the <a href="http://doc.qt.io/qt-5/qtest.html#qExec" rel="noreferrer">documentation</a> says if a test failed <code>qExec()</code> returns a non-zero value, which should mean all the following <code>qExec()</code> calls wouldn't happen, but this seems not to be the case.</p>

<p>What is the proper way to run multiple test classes? And so that I can see at a glance if any of the hundreds of unit tests I have have failed.</p>
