Results 1 to 5 of 5

Thread: QtTest bug

  1. #1
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QtTest bug

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QtTest bug

    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

  3. #3
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtTest bug

    Cheers, that helped I've now got it working.

  4. #4
    Join Date
    Feb 2006
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: QtTest bug

    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:
    Qt Code:
    1. #ifndef UFPBTESTLEXICO_H
    2. #define UFPBTESTLEXICO_H
    3.  
    4. #include <QObject>
    5. #include "lexico.h"
    6. #include <QtTest/QtTest>
    7.  
    8. namespace ufpb {
    9.  
    10. /**
    11. Classe para testar o as funcoes do lexico
    12.  
    13. @author Eduardo Santana <edusantana511-ufpb@yahoo.com.br>
    14. */
    15. class TestLexico : public QObject
    16. {
    17. Q_OBJECT
    18.  
    19. private slots:
    20.  
    21. void construtor();
    22. };
    23.  
    24. }
    25.  
    26. #endif
    To copy to clipboard, switch view to plain text mode 

    cpp file:
    Qt Code:
    1. #include "testlexico.h"
    2.  
    3. #include <iostream>
    4.  
    5. namespace ufpb {
    6.  
    7. void TestLexico::construtor(){
    8.  
    9. std::cout << "Testing Lexico here...";
    10.  
    11. }
    12.  
    13. QTEST_MAIN(TestLexico)
    14.  
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

    My src.pro file:
    Qt Code:
    1. CONFIG += qtestlib
    2. TEMPLATE = app
    3. TARGET += ../bin/compiladorufpb
    4. DEPENDPATH += .
    5. INCLUDEPATH += .
    6.  
    7. # Input
    8. HEADERS += lexico.h testlexico.h token.h ts.h
    9. SOURCES += compiladorufpb.cpp lexico.cpp testlexico.cpp token.cpp ts.cpp
    To copy to clipboard, switch view to plain text mode 

    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

  5. #5
    Join Date
    Feb 2006
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: QtTest bug

    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:

    Qt Code:
    1. #include "testlexico.h"
    2. #include <iostream>
    3. namespace ufpb {
    4. void TestLexico::construtor(){
    5. std::cout << "Testing Lexico here...";
    6.  
    7. }
    8. }
    9.  
    10. // outside of the namespace
    11.  
    12. QTEST_MAIN(ufpb::TestLexico)
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. qmake -project "CONFIG += qtestlib" -o TestLexico.pro
    To copy to clipboard, switch view to plain text mode 

    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.

Similar Threads

  1. QtTest: Unittesting in several classes
    By Jojo in forum Qt Programming
    Replies: 2
    Last Post: 25th August 2009, 12:38
  2. Using the subdirs TEMPLATE, having problems with dependencies
    By sadastronaut in forum Installation and Deployment
    Replies: 1
    Last Post: 3rd April 2009, 19:20
  3. I finally figured out how to do library dependencies.
    By sadastronaut in forum Installation and Deployment
    Replies: 1
    Last Post: 26th March 2008, 22:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.