How to test a Tcl/Tk script?

前端 未结 1 703
死守一世寂寞
死守一世寂寞 2021-01-06 11:07

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:

1条回答
  •  伪装坚强ぢ
    2021-01-06 12:05

    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.

    0 讨论(0)
提交回复
热议问题