Hello everyone !
I'm a in a professionnal licence (France) and i have issue on my tutored project.
I have a big problem on the Qt test framework and online tutorials I find didn't help me at all ... All take for exemple the ToUpper() method test, but the issue is because i didn't find how to use this freaking tests on my own classes ! T-T
I've some questions on QT Test:
-> do I made a .cpp and a .h for my test class ? Or putting all on the .cpp ?
-> I my class need to be in antoher project ? Or in the same project ? If i need to make another project, how to link both ?
-> do i need to importe .cpp of the class i need to test or the .h ? Or both maybe ?
This i the code of my test class:
#include <QString>
#include <QtTest>
#include "carre.h"
#include "cercle.h"
#include "point.h"
#include "rectangle.h"
#include "segment.h"
#include "figure.h"
#include "position.h"
class TestsProjetTest
: public QObject{
Q_OBJECT
public:
TestsProjetTest();
Carre* c;
Position* p;
private Q_SLOTS:
void testDeplacement();
};
TestsProjetTest::TestsProjetTest()
{
c = new Carre();
p = new Position(10, 10);
}
void TestsProjetTest::testDeplacement()
{
QVERIFY2(true, "Failure");
}
QTEST_APPLESS_MAIN(TestsProjetTest)
#include "tst_testsprojettest.moc"
#include <QString>
#include <QtTest>
#include "carre.h"
#include "cercle.h"
#include "point.h"
#include "rectangle.h"
#include "segment.h"
#include "figure.h"
#include "position.h"
class TestsProjetTest : public QObject
{
Q_OBJECT
public:
TestsProjetTest();
Carre* c;
Position* p;
private Q_SLOTS:
void testDeplacement();
};
TestsProjetTest::TestsProjetTest()
{
c = new Carre();
p = new Position(10, 10);
}
void TestsProjetTest::testDeplacement()
{
QVERIFY2(true, "Failure");
}
QTEST_APPLESS_MAIN(TestsProjetTest)
#include "tst_testsprojettest.moc"
To copy to clipboard, switch view to plain text mode
It's really a simple code which actually don't test anything, but i've some issues i didn't understand what can I do... There are the issues:
error: undefined reference to `Carre::Carre()'
error: undefined reference to `Position::Position(int, int)'
:-1: error: collect2: error: ld returned 1 exit status
error: undefined reference to `Carre::Carre()'
error: undefined reference to `Position::Position(int, int)'
:-1: error: collect2: error: ld returned 1 exit status
To copy to clipboard, switch view to plain text mode
It's really strange because methods work pretty well in my project and don't have any problems... I put NameOfMyClass:: for each method on my project, and it work ! So i don't understand why i have problems like that ...
I have there problems for one week and i didn't find a solution ... I really need help 
And please, dont redirect me on the ToUpper() tuto you find on Qt doc because i didn't help me at all ! 
Same thing for the tuto on developpez.net 
I hope you will find the problem and explain to me how to use Qt test framework ! I really need to improve my skill on it, because Qt will be my professionnal IDE, so i need to learn many things !
Thanks by advance !
Axel.
Bookmarks