Automating UI tests (was Re: Art of Unit Testing)

Joseph Andrew Knapka jknapka at earthlink.net
Fri Aug 17 20:33:46 CEST 2001


Boudewijn Rempt wrote:

> I've found little value in writing unittests for GUI apps

This is a subject that's been on my mind lately, and since the
subject has come up here, maybe some one can give me some pointers
on this matter:

How exactly would one go about automating unit tests of GUI code?
Specifically, I'm working on some UI stuff in Tkinter.
At first I thought, "well, I can just write tests that call
my Tk callback methods directly with appropriate values", but
then I realized that that can't work because my code
depends on the widget state (eg might call event.widget.get()
for a key-release event, or something like that).

So that means I'd need to write code that actually drives
the Tk widgets "from outside", as it were, either by synthesizing
events somehow at the OS/window-system level, or by knowing
enough about the Tk internals to convince the widgets that they're
being clicked on, typed at, etc. And at that point it looks like
a lot more effort than it's worth.

Can anyone suggest a workable approach to this problem?
Do wxPython or PyQt make this kind of thing any easier?
(I've looked at them both briefly, but am so used to
Tk that I would prefer not to switch with out a
compelling reason.)

Thanks,

-- 
# Joe Knapka
# "You know how many remote castles there are along the
#  gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald
# 2nd Lbl A + 1 = 2nd Pause 2nd Prt A
-- 
# Joe Knapka
# "You know how many remote castles there are along the
#  gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald
# 2nd Lbl A + 1 = 2nd Pause 2nd Prt A



More information about the Python-list mailing list