开发者

Qt unit test dependency problem

开发者 https://www.devze.com 2023-02-22 06:53 出处:网络
Hee, I\'m kinda new to Qt and i started to add UnitTests to my Qt project. Qt demands that i put my unit tests in another project, so i did.

Hee,

I'm kinda new to Qt and i started to add UnitTests to my Qt project. Qt demands that i put my unit tests in another project, so i did. But now i have dependent source files in my first project. I made my 'main project' a dependency of my 'test project'. I cannot seem to include any of the '.h' files from my 'main project'. The unit test them self run properly as long as i do not use classes from my 'main project'.

I looked into the Qt documentation, but i cannot find the solution for my problem. Am i开发者_如何学运维 missing something?


Did you try to include your dependencies to .pro file of your test project?

HEADERS += ../MyHeader.h
SOURCES += ../MyHeader.cpp \
      tst_myUnitTestName.cpp


You can try adding the path of your main program in the includes (in the testProject.pro file)

INCLUDEPATH += .. .

(or just add the path to the project itself)

if you do this, you will then need to change your includes (in the .cpp files) from "" to <>

#include < MyHeader.h >

Adding the headers to the .pro file will mostly allow you to have easy access to the file itself if you're using QtCreator (and qmake will complain if it doesn't find the files), but it will not solve the actual dependencies within each .cpp file.

0

精彩评论

暂无评论...
验证码 换一张
取 消