Qt Unit testing Error Please Help!!
-
wrote on 18 Oct 2019, 11:08 last edited by
I was trying to execute the sample unit test for Gui Element !
#include <QString>
#include <QtTest>
#include<QtWidgets>class Sample_Unit_Testing : public QObject
{
Q_OBJECTpublic:
Sample_Unit_Testing();private Q_SLOTS:
void tst_Gui();
};
void Sample_Unit_Testing::tst_Gui()
{
QLineEdit line_edit;
QTest::keyClicks(&line_edit,"abcd");
QCOMPARE(line_edit.text(),QString("abcd"));
}this is my code, When i run this code i get an error which says
QFATAL : Sample_Unit_Testing::tst_Gui() QWidget: Must construct a QApplication before a QWidget
FAIL! : Sample_Unit_Testing::tst_Gui() Received a fatal error.Can anybody explain it me about the error and help??
-
I was trying to execute the sample unit test for Gui Element !
#include <QString>
#include <QtTest>
#include<QtWidgets>class Sample_Unit_Testing : public QObject
{
Q_OBJECTpublic:
Sample_Unit_Testing();private Q_SLOTS:
void tst_Gui();
};
void Sample_Unit_Testing::tst_Gui()
{
QLineEdit line_edit;
QTest::keyClicks(&line_edit,"abcd");
QCOMPARE(line_edit.text(),QString("abcd"));
}this is my code, When i run this code i get an error which says
QFATAL : Sample_Unit_Testing::tst_Gui() QWidget: Must construct a QApplication before a QWidget
FAIL! : Sample_Unit_Testing::tst_Gui() Received a fatal error.Can anybody explain it me about the error and help??
Hi @Amogh,
do you use QTEST_MAIN? If not, please show your main function resp. use
QTEST_MAIN
.Regards
1/2