I am trying to create a new test class for each of my classes in QT. I have this working with a single file, but that relies on QTEST_MAIN creating an application for me and calling it in more than 1 file creates a multiple definition error.
I have tried creating a main() on my own and then running a qExec, but I have been unsuccessful. I am using SCONS to build and haven't found any resources on making that work within that build system.
Here is my latest failed attempt:
#include <QtTest/QtTest>
#include "path/test1.h"
#include "path/test2.h"
class TestMain : public QObject {
Q_OBJECT
private:
TEST1 test1;
TEST2 test2;
private Q_SLOTS:
void initTestCase();
};
void TestMain::initTestCase(){
//these are causing multiple def of main
test1.initTestCase();//these only have data to setup the UI to test on
test2.initTestCase();//these only have data to setup the UI to test on
}
QTEST_MAIN(TestMain);
Is there a clean way to achieve something like this without using the QTEST_MAIN macro, or using it to call a single slot that then collects all the tests from the separate classes?
All the other solutions I've found make a new main and I would rather not do that due to the fact that it creates more setup issues such as creating a QApplication that would have to accept parts from all the classes and duplicated code.