views:

37

answers:

1

I am attempting add some tests to an existing QT GUI application using QTest. The GUI uses quite a bit of complicated start-up code so I'd rather not write another main() to start it again.

To me, it seems like the easiest way would be instantiate the app and then run the tests on it. I am just not sure, however what function I could plug my test object into so that I don't block the flow of messages.

I could send a special message to start the test or set a timer but that's complicated and tests are supposed to simplify things.

So where would be the best place in existing GUI to insert and qexec a Qtest object?

+1  A: 

I'm willing to be proven wrong, but test frameworks in general (and QTest specifically from what I've used of it) tend to assume that the test framework will be driving the code to be tested, as opposed to running along side of it.

I'm also concerned about "The GUI uses quite a bit of complicated start-up code...." Are you intending on testing the startup code? Or testing other stuff around it?

Generally speaking, when I start looking at adding tests to an application, I try to find smaller pieces that are used in a lot of the application, and write tests for those. I then build up to testing the bigger pieces that integrate those smaller ones. My general idea is that if the small pieces work properly, then either I've put them together correctly and things should work, or I haven't and things should obviously fail when I try to run the application.

I should mention that there are other options for testing GUIs for Qt applications in particular. They tend to be more like scripts run on your program, with the output recorded. If that interests you, then you could look into Squish for Qt.

Caleb Huitt - cjhuitt
Plus one for the info, I think you've answered it and I'll verify tomorrow but have you the seen license, prices and terms for Squish? - Woa!
Joe Soul-bringer
@Joe, I haven't actually looked at the prices or terms for Squish. I just knew something was out there, having seen a link to it before, and found it with a reasonably quick google search.
Caleb Huitt - cjhuitt
Sure, just a heads-up that some of these nice looking frameworks that pop-up come with "interesting" terms like 1-2K euros/head/year.
Joe Soul-bringer