Finally, it turned out how to run tests before running the application.
I added one static method in the test class to run the tests:
#include <QtTest/QtTest>
TestClass::runTests()
{
TestClass * test = new TestClass();
QTest::qExec(test);
delete test;
}
In the main function, do:
int main(int argv, char *args[])
{
::TestsClas::runTests();
QApplication app(argv, args);
MainWindow mainWindow;
mainWindow.setGeometry(100, 100, 800, 500);
mainWindow.show();
return app.exec();
}
.