tags:

views:

24

answers:

1

We have a few Tcl/Tk scripts (because a GUI we use can incorporate macros only in Tcl). I have just modified one of these, and want to test it.

We make use of Test::More for testing Perl modules, and have made a little use of Selenium for web pages, but we have never had any kind of automatic test rig for our Tcl/Tk scripts.

I've tried searching, but because Tcl's original purpose was for testing, I've found it difficult to sort out if there are any hits about testing Tcl/Tk itself.

Does anybody know of a program which will let me run a Tcl/Tk script, and test its user interaction as well as its eventual operation?

+3  A: 

Are you asking specifically about GUI testing, or testing of Tcl scripts that may or may not have a GUI component?

Tcl comes with tcltest, which is quite useful for testing tcl scripts. It lets you specify expected values, flag tests to run only on certain platforms, etc.

To test GUIs there's no clear cut answer. The tcl'ers wiki lists a few choices. However, since Tcl is a scripting language, you can easily write scripts that drive your application without the need for a fancy harness. What I've done in the past is create commands like "press_button" (eg: press_button "Open") which looks for a button that has the label "Open" and invokes its callback. With Tcl's powerful introspection capabilities, things like this are quite easy.

The only real gotcha is when dealing with menus on Windows, since those are implemented with native controls so it's a bit harder to interact with them.

Bryan Oakley
Thanks. Yes, I am asking about GUI testing. I'll follow your link on the Wiki.
Colin Fine
As Bryan knows, not only does Tcl/Tk support the GUI testing rigs he described at a technical level, but the Tcl community has a rich tradition of accomplishment in regard to testing. The testing harness for gcc, for example, is founded on Tcl. The point for Mr. Fine should be to have high expectations for what he can achieve in automation of tests focused on Tk. He's sure to receive plenty of help, if he should run into difficulties.
Cameron Laird