4
votes

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?

1

1 Answers

6
votes

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.