I've partialy analysed AutoTest code.
For QTest it checks if given source file (after macro preprocesing) has QTest include and QTest::exec() somewhere in code.
In my case it lead to usage of TestRunner modified to store function object
#define DECLARE_TEST_RUNNER(className) \
namespace { \
int executeTestClass(int argc, char* argv[]) \
{ \
className test; \
return QTest::qExec(&test, argc, argv); \
}; \
static char test_##className = \
TestRunner::Instance().RegisterTestClassRunner(executeTestClass); \
}
Macro is placed at begining of each CPP file with test details (to decouple as much as possible)
However Autotest still acts strangely. Sometimes it discover tests, sometimes not. I believe that it may search in source context of currently selected run target.
PS: When I expanded one of DECLARE_TEST_RUNNER macro - AutoTest start displaying green arrows. Not before. Building main exe or ut.exe isn't helping.
Calling 'Refresh test' from Tools->Tests also doesn't help. I still don't know what triggers test gathering.
PSS: In each test binary at least one QTest::qExec should be expanded out of MACRO. From this point - AutoTest shows also test runners hidden in MACRO and run then all.