PDA

View Full Version : QtTest bug



graeme
11th February 2006, 13:53
In 4.1.0 I can't run QtTest because of the following error.

.../include/QtTest/qtestkeyboard.h:33:49: error: QtTest/private/qtestspontaneevent_p.h: No such file or directory
This is a reported error and is scheduled to be patched in release 4.1.1

Does anyone know when the next patch will be out or know how to fix this?

Codepoet
11th February 2006, 14:03
The file is in the official archive or at least qt-x11-opensource-src-4.1.0. Copy the file from there to the include path: .../QTest/private

graeme
11th February 2006, 18:33
Cheers, that helped I've now got it working.

klansm
19th February 2006, 17:17
I'm not sure on how QtTest/QtTest works yet.

I have copied the private folder AND tools folder to the instalation directory.
I'm using qt4 and KDevelop.

So I have a src.pro file, with all the sources and header files plus

CONFIG += qtestlib

I have a 'Lexico' class and a 'TestLexico' class that looks like this:

#ifndef UFPBTESTLEXICO_H
#define UFPBTESTLEXICO_H

#include <QObject>
#include "lexico.h"
#include <QtTest/QtTest>

namespace ufpb {

/**
Classe para testar o as funcoes do lexico

@author Eduardo Santana <edusantana511-ufpb@yahoo.com.br>
*/
class TestLexico : public QObject
{
Q_OBJECT

private slots:

void construtor();
};

}

#endif


cpp file:


#include "testlexico.h"

#include <iostream>

namespace ufpb {

void TestLexico::construtor(){

std::cout << "Testing Lexico here...";

}

QTEST_MAIN(TestLexico)


}

My src.pro file:

CONFIG += qtestlib
TEMPLATE = app
TARGET += ../bin/compiladorufpb
DEPENDPATH += .
INCLUDEPATH += .

# Input
HEADERS += lexico.h testlexico.h token.h ts.h
SOURCES += compiladorufpb.cpp lexico.cpp testlexico.cpp token.cpp ts.cpp

It compiles fine, and generates the compiladorufpb executable, witch is a Hello world application, for now. But, how can I generate the EXECUTABLE TEST for that class ? Does it going to generate one executable for eache TestClass I create ? What else should be done ?

I would be very glad if someone help :)

klansm
19th February 2006, 21:16
I was finaly able to make it work!

It turns out that it had to make an other .pro file, taking off all the classes we wouldn't need. And change the QTEST_MAIN() macro position of the cpp file:


#include "testlexico.h"
#include <iostream>
namespace ufpb {
void TestLexico::construtor(){
std::cout << "Testing Lexico here...";

}
}

// outside of the namespace

QTEST_MAIN(ufpb::TestLexico)


The QTEST_MAIN macro should be outside of you namespace, and use the full name of your class in the macro.


qmake -project "CONFIG += qtestlib" -o TestLexico.pro

This will genarates an new .pro file.
Strip off all the unsed files. Let only the files and header for the test you want. (Be sure to remove the main file of your project).

Then a call to 'qmake TestLexico.pro' to generate the Makefile. And make to genarates the executable, in this case: TestLexico.