Mikster has asked for the wisdom of the Perl Monks concerning the following question:

Having just read Damian Conway's recent article at perl.com, 10 Essential Development Practices (which is actually a partial excerpt of his new book, Perl Best Practices), I was all inspired to be the best Perl coder I could be... until I realized that I'm doing a lot of Perl/Tk coding right now, and haven't a clue how you'd apply Test::Simple or Test::More to a piece of event-driven GUI Tk software.

So, I seek the wisdom of the ages... how do you apply automated testing to software that's all about mediating asynchronous, graphical user input? I shudder to think what would be required to drive the mouse via software, and test every function... and then somehow determine if the output matches the desired output.

Ideas? Suggestions?

Replies are listed 'Best First'.
Re: Perl/Tk and Test::Simple/More
by Euclid (Sexton) on Jul 18, 2005 at 23:46 UTC
    A GUI application (Perl/TK in this instance) has two parts - the user interface (the TK stuff) and the back end work. Structure your application in such a way that you can test the back end routines independently of the user interface. At least you will have verified the functionality of the program.
Re: Perl/Tk and Test::Simple/More
by rinceWind (Monsignor) on Jul 18, 2005 at 21:55 UTC

    A good place to start would be to look at the tests that come with Tk. If you have ever run "make test" against a Tk distribution, you will see various widgets appear on the display and disappear.

    The main point is that tests for a Tk module won't actually be able to verify what the widgets actually look like, but should be able to check that they behave correctly. It is possible to fake mouse and keyboard events by using the pseudoevent mechanism.

    Hope this helps

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)