APR
23
2006

Unit testing tutorial gets another step

I've just added another section to an example-based tutorial I've been working on. The tutorial aims to describe what you need to know to be able to write unit tests for Qt and KDE, using the QTestLib test framework.

The latest section covers testing of QObject subclasses using signals and slots. Slots are easy (because they are really just normal methods that you can call using some special syntax). Signals requires a bit more work, although Qt provides the elegant QSignalSpy class which makes things look fairly neat. You can read the tutorial at http://developer.kde.org/documentation/tutorials/writingunittests/writingunittests.html

In the longer term, I'd like to use this as part of a on-line training course. More about that when I figure out whether it is going to work or not.

I also liked Frans' idea of using the material on http://developer.kde.org to write a KDE developer's book. Of course, my tutorials are already in docbook. Such an activity would also give us a chance to clean up and update the various tutorials to match the current state of the art in KDE.

Comments

I've just finished reading the book Extreme Programming Explained and there testing is very important part of application development. And since I'm learning KDE and Qt programming for quite some time now I was wondering how could it be done with Qt/KDE. And this article seams to be just perfect for me. Thanks for working on it. It is a nice resource for people like me who are new to Qt/KDE programming. I sure hope we see more articles like this. And I sure hope we'll see a book like KDE 4 development. I got the book for KDE 2 a few months ago (thanks to Christian Tibirna) but it is a bit old so a new book for KDE 4 would be awsome. And this time I would buy two copis and donate one to our local library.

--
Live long and prosper!
JLP's Blog - http://jlp.holodeck1.com/blog/


By Jure Repinc at Sun, 04/23/2006 - 13:34

It seems like writing unit tests for kde 4 might make a nice junior job - it gets you into the code, but doesn't require in-depth knowledge of how everything fits together before you can start producing results. Is that reasonable? If so, I'll consider suggesting it to people who pop up on kde-quality etc.


By philrod at Sun, 04/23/2006 - 19:24

I think it can work well for classes that already have some documentation. If you don't have examples, and don't have documentation, then figuring out what the classes is supposed to do (rather than testing what it does) is a bit hard.

Another JJ would be to create a unit test that shows a particular bug. These could then be attached to the bug report.


By brad hards at Tue, 04/25/2006 - 04:07

Thanks for the comments, I'll bear them in mind when talking to new contributors.


By philrod at Thu, 04/27/2006 - 17:08