Hello,
i have the same problem.
I found a "workaround" how it works:
If you build the sampleapp as a library:
sampleapp.pro:
TEMPLATE = lib
TARGET = lib
DEPENDPATH += . inc src
INCLUDEPATH += . inc src
HEADERS += painter.h
SOURCES += painter.cpp [B]#without main.cpp[/B]
TEMPLATE = lib
TARGET = lib
DEPENDPATH += . inc src
INCLUDEPATH += . inc src
HEADERS += painter.h
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:
TEMPLATE = app
QT += testlib
TARGET =
LIBS += lib.so # built by sampleapp
DEPENDPATH += . inc src ../sampleapp/inc ../sampleapp/src
INCLUDEPATH += . inc src ../sampleapp/inc ../sampleapp/src
# Input
HEADERS += sampleapp-tests.h
SOURCES += sampleapp-tests.cpp
TEMPLATE = app
QT += testlib
TARGET =
LIBS += lib.so # built by sampleapp
DEPENDPATH += . inc src ../sampleapp/inc ../sampleapp/src
INCLUDEPATH += . inc src ../sampleapp/inc ../sampleapp/src
# Input
HEADERS += sampleapp-tests.h
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:
MyPrject
|---Core # TARGET = app
| |--core.h
| |--core.cpp
|---CoreTest # tests the core-class
|--main.cpp
MyPrject
|---Core # TARGET = app
| |--core.h
| |--core.cpp
|---CoreTest # tests the core-class
|--main.cpp
To copy to clipboard, switch view to plain text mode
?
Need help, thank you in advice.
Bookmarks