[Interest] Unit testing: any best-practices tips ?
Bo Thorsen
bo at fioniasoftware.dk
Tue Dec 13 18:29:24 CET 2011
Den 13-12-2011 15:32, Frans Klaver skrev:
>> c) Is it possible to have multiple targets in one pro file ? (And if
>> > so is this a Good Idea(TM)?)
> Can't remember, and usually not.
It is not only possible, but even my preferred method when using qmake.
I have a top level pro file that looks like this:
TEMPLATE = subdirs
SUBDIRS += unittest application
In the application dir, I have the pro file that builds the real
application. The unittest dir builds the unit test. (Well, doh!)
I still use .pri files for all the sub modules (model, ui, ...) and each
of the two pro files include those. Usually, my pro file only include
the main.cpp in the sources list and no headers. All source code is
hidden away in modules that are shared between the app and the test.
Finally, the test has this qmake code:
CONFIG(debug, debug|release) {
QMAKE_POST_LINK = $${OUT_PWD}/debug/$${TARGET}$${TARGET_EXT}
}else {
QMAKE_POST_LINK = $${OUT_PWD}/release/$${TARGET}$${TARGET_EXT}
}
This runs the unit test application after a build.
So I have the app project as the startup project, and the build process
runs the unittest application. Perfect :)
Someone mentioned using cmake. That's great as well, and I use it
whenever I'm on Visual Studio and not deploying on Symbian or Meego. On
my website (http://www.fioniasoftware.dk) there is an example
application with full unit test setup for cmake. I've been meaning to
rewrite this to qmake code, but didn't find the time yet.
I hope this helps.
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
More information about the Interest
mailing list