PDA

View Full Version : How to install my own application in QUnitTest



Artschi
18th July 2006, 12:12
Hi,

I need to create an application instance (which is derived from QApplication) in a QUnitTest. This application instace require argc/argv as given in main().

All single test steps of the QUnitTest will use this application instance.

Are there any ideas how to arrange that?

Thanks Artschi

wysota
18th July 2006, 12:17
What is QUnitTest? Why do you want to subclass QApplication? QApplication already has support for argc and argv...

Artschi
18th July 2006, 15:30
QUnitTest is the Qt's UnitTest framework, right? And it is definitly not my problem, if it is a good decission to subclass QApplication. That is given to me.

To be more precise:

There is a
class XApplication : public QApplication
that has to be instantiated at the very beginning of main() in the same way as a QApplication instance has to be created:

main(int argc, char *argv[]) {
Xapplication appl(argc, argv);
// ...
}

In the Qt UnitTest framework the main() is not accessable and the question is:
How to create an XAppliation instance in the Qt UnitTest application.

wysota
18th July 2006, 16:05
QUnitTest is the Qt's UnitTest framework, right?
You mean QTestLib?


In the Qt UnitTest framework the main() is not accessable and the question is:
How to create an XAppliation instance in the Qt UnitTest application.
This is not true. You may skip using QTEST_MAIN() macro and implement your own main(). The macro is only for convenience. It is defined as:


#define QTEST_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
QApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}