Switching to QtTestLib for unit tests

Jeroen Wijnhout Jeroen.Wijnhout at kdemail.net
Sat Sep 3 13:03:20 BST 2005


On Saturday 03 September 2005 11:52 am, David Faure wrote:
> I wasn't initially in favour of switching to qttestlib, but then I saw
> Harald's presentation of it (see below for a list of advantages), and I
> also ran into problems with kunittest: the whole idea of dlopened modulesr
> falls apart in kdelibs. The test module links to libkdecore.so, and when
> dlopening it from kunittestmodrunner it would use the system libkdecore.so
> instead of the one in ../.libs. Libtool can use local libs when launching a
> program, but there's no solution for dlopening modules. My reason for
> pushing dlopened modules was to simplify the code to write for each test
> program, but another solution for that is simply a macro containing the
> whole main() of the test program, like qttestlib does.

FYI, it will be quite trivial to remove the dependence on kdecore (it is only 
needed because KUnitTest needs a KInstance, which is not strictly needed 
(that is, if one doesn't care about the "debug output capturing" feature).

> Here's a list of other things that qttestlib provides over kunittest:
>
> * More flexible data-type support (one can't do
> CHECK(QStringList,QStringList) with kunittest because that type isn't
> printable with <<, for instance; qttestlib uses template specialization so
> it works fine there)
> * Data-driven testing (see the online tutorial)
> * GUI automation (send fake key events and mouse events to widgets)
> * Signal introspection (count how many times a signal was emitted, and
> check with which values) * XML output (for GUIs)
> * Verbose output (shows variable values also in working tests) / signal
> slot dumper * Comments attached with expected failures
> * Additional message can be passed to VERIFY macro check, e.g. DB error
> message. * Support for checking that a qDebug/qWarning message was shown
> * Simpler framework (no test runner, and no GUI)

KUnitTest in kdelibs is also without a GUI, but indeed QtTestLib offers quite 
some advantages.
 
> But of course the idea would be that the kdesdk/kunittest GUI could be
> ported to qttestlib. I don't plan on working on that myself though, my main
> use for unit-testing is "make check" type of thing, mostly in kdelibs.
>
> OK with everyone?

Count me in! If I can find some time I will try to port the GUI to QtTestLib, 
unless someone else, with too much spare time, wants to do it ;-)

best,
Jeroen
-- 
Kile - an Integrated LaTeX Environment for KDE
http://kile.sourceforge.net




More information about the kde-core-devel mailing list