3

Is it possible to run an application and on top of that, you send keyPress events to the app and test the results using qtestlib?

If yes, can somebody give me an example how to do it?

If no, can somebody show me a better way accomplish the above requirement?

Thanks...

Owen
  • 4,063
  • 17
  • 58
  • 78
  • 1
    Testing applications this way is very difficult since the results depend on window positioning, screen resolution, ... If possible, split the UI from the business-logic of the application, and write tests on top of the business-logic. – Patrick Nov 19 '10 at 07:34
  • 1
    There are tools to do this, e.g. Squish (from froglogic). I tried to do something like this myself once, by sending events from the code, but it ended in pain. I *still* have headaches from this sometimes. – Ivo Nov 19 '10 at 07:55
  • http://stackoverflow.com/questions/21606125/qt-event-loop-and-unit-testing/22951970#22951970 – peter karasev Apr 09 '14 at 03:00

2 Answers2

2

Easy answer: No.

There are tools to do this however. Ivo mentioned Squish, there's also "native" testing application called QtUiTest which can be found here: http://qt.gitorious.org/+qa-tools/qt-labs/qa-tools-qtuitest .. and TDriver here: http://gitorious.org/tdriver

rasjani
  • 7,372
  • 4
  • 22
  • 35
  • is there a software similar to squish but is free? – Owen Nov 25 '10 at 06:02
  • How much "free-er" you want ? both tools above are linked directly to their sourcecode hosting sites. Are they similar, propably not .. but they do the same job anyway as squish. – rasjani Nov 25 '10 at 07:29
0

I would argue that what you are proposing is not unit testing, but system testing. There is certainly a place for system level tests of a GUI application, but you do have to understand the differences and limitations of full-program testing if you are coming from a unit-testing heavy background.

That being said, I really like froglogic's Squish. It has a number of neat features:

  • It directly accesses Qt objects, so there is generally little need for pixel based actions
    • This is specifically the problem with almost every other GUI testing tool, as Patrick mentioned in the comments to the original question.
  • It can be linked to your Qt library, if you have a custom version (we do :) )
  • Tests are scripted in Python (or tcl, or javascript, etc.)
  • Tests can be recorded based on mouse/keyboard actions.
    • Even these tests are in your scripting language, so they can be easily refactored or extended.
  • There are a variety of cool verification options.
  • It runs on Mac, Linux, and Windows (and I think iOS)
  • It can run in client/server mode, so you can start tests on a variety of machines from a single launch point (or from your build system).
  • froglogic has a list of what they think is cool, too.
Community
  • 1
  • 1
dbn
  • 13,144
  • 3
  • 60
  • 86