[SOLVED] QTest example doesnt work
-
wrote on 2 Dec 2015, 17:01 last edited by Aram 12 Mar 2015, 07:54
Hi all,
I'm trying to follow QTest example here to make a unit test but it gives me this errors/home/aram/MEGA/proj/scratch/test/Qt_Test_Tutorial/tut_1/main.cpp:6: error: undefined reference to `vtable for TestQString'
My code is the same as it is in the example.
I'm using Qt development environment from my distribution (opensuse leap 42.1)
Thanks. -
hi
do you have Q_OBJECT
in your class ?
Try to delete the build folder.
Then run qmake
then rebuild all -
wrote on 3 Dec 2015, 04:23 last edited by
of course i have... as i said, it just a copy
-
Lifetime Qt Championwrote on 3 Dec 2015, 07:46 last edited by mrjj 12 Mar 2015, 07:47
@Aram
ok
also the
#include "testqstring.moc"
with the correct name ?
#include "main.moc"
(must match the file name)
This will make the moc.exe tool run on the CPP file. Normally this
tool only runs on .h files but Test unit are special and the include makes sure
moc.ex is run on the file.
The reason I ask is that the eror you get is very like what you get when moc.exe not been run on file. -
@Aram
ok
also the
#include "testqstring.moc"
with the correct name ?
#include "main.moc"
(must match the file name)
This will make the moc.exe tool run on the CPP file. Normally this
tool only runs on .h files but Test unit are special and the include makes sure
moc.ex is run on the file.
The reason I ask is that the eror you get is very like what you get when moc.exe not been run on file.wrote on 3 Dec 2015, 07:52 last edited by@mrjj yes i had those things,,, i solved the problem by removing additional config lines (that qt_creator adds when you create a project) from *.pro file and left it only with
QT += core testlib SOURCES += testfile.cpp
and now it works...
-
@mrjj yes i had those things,,, i solved the problem by removing additional config lines (that qt_creator adds when you create a project) from *.pro file and left it only with
QT += core testlib SOURCES += testfile.cpp
and now it works...
@Aram
Ok. thanks for posting solution.
4/6