Results 1 to 2 of 2

Thread: qmake project setup - qtestlib scenario

  1. #1
    Join Date
    Apr 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question qmake project setup - qtestlib scenario

    Hello all,

    I am trying to setup some structured generic project skeleton and running into a problem separating qtlibtest into subproject, as those should not be built in as part of the application, and I am trying to use some structured project setup as I do not like all files just being in one folder (I am in general a Java developer).. I have spent a half day searching the internet have not found anything.

    sampleapp-project.pro:
    TEMPLATE = subdirs
    CONFIG += ordered
    SUBDIRS = sampleapp sampleapp-tests

    sampleapp.pro
    TEMPLATE = app
    TARGET =
    DEPENDPATH += . inc src
    INCLUDEPATH += . inc src
    HEADERS += painter.h
    SOURCES += painter.cpp main.cpp

    sampleapp-tests.pro
    TEMPLATE = app
    QT += testlib
    TARGET =
    DEPENDPATH += . inc src ../sampleapp/inc ../sampleapp/src
    INCLUDEPATH += . inc src ../sampleapp/inc ../sampleapp/src

    # Input
    HEADERS += sampleapp-tests.h
    SOURCES += sampleapp-tests.cpp

    There exist painter.h and painter.cpp defining Painter object under sampleapp project.

    My problem is trying to use this Painter object from class PainterTest which is under sampleapp-tests project, receiving "undefinied reference to 'Painter:Painter()' when building.

    If I look at the compile output, the test is not linking against objects from the sampleapp:

    g++ -o sampleapp-tests debug/sampleapp.o debug/moc_sampleapp.o -L/usr/lib -lQtTest -lQtGui -lQtCore -lpthread

    I very appreciate any help on:

    - how to make this scenario work
    - is this the way project should be setup, are there any guidlines and may be tutorials on this ?

    thank you in advance

  2. #2
    Join Date
    Jun 2011
    Posts
    1
    Platforms
    Unix/X11

    Default Re: qmake project setup - qtestlib scenario

    Hello,

    i have the same problem.

    I found a "workaround" how it works:

    If you build the sampleapp as a library:
    sampleapp.pro:
    Qt Code:
    1. TEMPLATE = lib
    2. TARGET = lib
    3. DEPENDPATH += . inc src
    4. INCLUDEPATH += . inc src
    5. HEADERS += painter.h
    6. SOURCES += painter.cpp [B]#without main.cpp[/B]
    To copy to clipboard, switch view to plain text mode 
    and then change sampleapp-tests.pro to:
    Qt Code:
    1. TEMPLATE = app
    2. QT += testlib
    3. TARGET =
    4. LIBS += lib.so # built by sampleapp
    5. DEPENDPATH += . inc src ../sampleapp/inc ../sampleapp/src
    6. INCLUDEPATH += . inc src ../sampleapp/inc ../sampleapp/src
    7.  
    8. # Input
    9. HEADERS += sampleapp-tests.h
    10. SOURCES += sampleapp-tests.cpp
    To copy to clipboard, switch view to plain text mode 
    It works this way! But does it mean that i only can do unit testing with libraries? how can i test projects which were built as TEMPLATE = app?

    Or: does it mean that my unit testing classes have to in the same project as my classes that i want to test? Is there a way i can have:
    Qt Code:
    1. MyPrject
    2. |---Core # TARGET = app
    3. | |--core.h
    4. | |--core.cpp
    5. |---CoreTest # tests the core-class
    6. |--main.cpp
    To copy to clipboard, switch view to plain text mode 
    ?
    Need help, thank you in advice.

Similar Threads

  1. making Eclipse recognize project dependnecies with qmake?
    By akos.maroy in forum Installation and Deployment
    Replies: 5
    Last Post: 20th January 2009, 13:05
  2. qmake -project problems
    By khopper in forum Newbie
    Replies: 2
    Last Post: 28th September 2008, 13:51
  3. making qmake create VisualStudio console app project file?
    By akos.maroy in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2008, 14:45
  4. qmake project dependencies
    By akos.maroy in forum Newbie
    Replies: 1
    Last Post: 15th June 2008, 13:52
  5. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57

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.