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

Srdjan Todorovic todorovic.s at googlemail.com
Fri Feb 20 17:26:46 CET 2009


Hi,

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?

> 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.

> 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!

I have a .pro file at home where I've had my test class files reside
in the same directory as my application classes. I know this isn't
what you wanted, but it worked quite well for me.

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.

Srdjan



More information about the Qt-interest-old mailing list