[Interest] How to use unit testing with Qt framework properly
Gilles Habran
gilleshabran at gmail.com
Tue Apr 10 10:29:16 CEST 2012
Hi guys,
I have a personal project and I would like to try to use Test Driven
Development. For the moment, my only knowledge in Unit Tests come from
several books, I never really use that concept in a project.
Here is the arch of my project folder :
xxx/xxx.pro
xxx/src/*.cpp
xxx/include/*.h
xxx/obj/*.o
xxx/bin/
xxx/tests/yyy.pro
xxx/tests/*.cpp & *.h
So I have two projects, one for the main project and one for the tests,
because I read that it's better that the tests do not mess with the project
and I agree with that.
For my test project, I plan to have a main.cpp that controls all the tests
and my tests classes like this : testAAA.cpp+testAAA.h
My problem is that I don't know how to "link" my project with unit tests to
my main project.
I read that I should either link my main project object files (.o) with my
test project or have some .so to link to (my main project is not a library,
it will have a GUI, DB access, XML, ... so how should I get that .so ?) or
finally, add all the files mainProject.cpp and mainProject.h to the unit
tests project to have access to them while compiling the project with unit
tests.
Can someone help me with documentation or good practice with unit testing
with Qt (blog post, ...) ?
I already have read the documentation for Qt Test Lib and I tested it (I
included the .cpp in my test project files but it seemed really ugly) and
it worked fine so I just need advises how to do it the proper way.
Thanks a lot.
Kind regards,
GH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120410/9fb89f56/attachment.html>
More information about the Interest
mailing list