[Qt-interest] Project directory tree with test code subtree (TDD)

Islam Samir Badreldin islam.badreldin at gmail.com
Sat Feb 21 12:53:38 CET 2009


Hello Srdjan
> 2009/2/14 Islam Samir Badreldin <islam.badreldin at gmail.com>:
>   
>> I am trying to create a new _large_ project with Qt. I want to do unit
>> testing for every class I have in this project (sort of TDD). I am
>> asking about how to use 'qmake' in such scenario?
>>
>> My hierarchy may look something like this:
>>
>> trunk----> src -->
>>      |
>>      --> test -->
>>
>> I want the 'test' tree to mirror that of the 'src' tree. What I want to
>> have is to be able to call 'qmake' then 'make' under _any_ directory in
>> the 'test' tree and have the Makefile automatically _link_ (not compile)
>> the needed *.o files from the 'src' tree (i.e. the object code of the
>> classes I am currently testing). I assume here that the *.o files
>> actually exist in their proper place under the 'src' tree.
>>     
>
> Won't make only compile your test classes if they have changed?
>   
Yes, I use the Eclipse CDT IDE. I set the properties of the test project 
to refer to the other project I am testing. This way, just hitting the 
build button for the test code automatically rebuilds the _tested_ code 
without requiring me to do anything!
>   
>> In short: I want the Makefile to _link_ some additional object files
>> from another directory other than the current build directory!!
>>     
>
> Could you do this using SOURCES += and HEADERS += in the .pro file?
> Then just qmake and create the new makefile?
> As long as your test classes havn't changed, they wont be recompiled,
> and they will only be linked with the main application.
>   
The SOURCES += only works if the test code is in the same directory as 
the production code. They need to share the same OBJECTS directory.
>   
>> Is this a possible setup for the project using 'qmake'? If not, what is
>> the perfect setup for TDD with Qt and 'qmake'? Any help on this is
>> largely appreciated!
>>     
>
> Lately I've also set a variable in the .pro file and let that be a
> conditional that decides if source in subdirectories have the test
> classes pulled into the makefile.
>
> I can post more details if you are interested. I've only ever done TDD
> with EasyUnit, though I should try out the Qt4 test framework at some
> point.
>
>   
Yes please, posting more detail is appreciated. Currently I am following 
the directory structure of QwtPlot with minor modifications. It works 
great for me, especially with the Eclipse CDT + Qt integration. I can 
import Qt projects using the (Import...) feature without moving the Qt 
projects from their places. This way I can develop in Eclipse and 
maintain a robust project tree in the same time.

Regards,
Islam



More information about the Qt-interest-old mailing list