I have some unit tests for my project that I did with the QtTest framework. It is a console application, and actually I don't use anything from Qt apart from QtTest.
On my computer it works fine, however I am setting up continuous integration on Travis and I get :
lib_testapp: cannot connect to X server
I tried running my app with -platform offscreen
as I saw on another thread but it doesn't seems to change anything.
There are these lines in the .pro :
TEMPLATE = app
CONFIG += console c++11
QT += testlib
My main.cpp
looks like this :
class WatermarkingTests: public QObject
{
Q_OBJECT
private slots:
void initTestCase() { }
void test1() { someTest(); }
void cleanupTestCase() { }
};
QTEST_MAIN(WatermarkingTests)
#include "main.moc"
someTest()
is a purely mathematical function which makes some calls to QVERIFY
.
Thanks!
Your problem is the following line:
From the documentation:
This means, you will get a QApplication rather than QCoreApplication since the
QT
variable contains core and gui by default. You would need to use the following statement to get around it:Note that with Qt 5, you can just the following macro instead: