如何测试 Tcl/Tk 脚本?
我们有一些 Tcl/Tk 脚本(因为我们使用的 GUI 只能在 Tcl 中合并宏)。 我刚刚修改了其中之一,想测试一下。
我们使用 Test::More 来测试 Perl 模块,并在网页中使用一点 Selenium,但我们从来没有为我们的 Tcl/Tk 脚本提供任何类型的自动测试装置。
我尝试过搜索,但由于 Tcl 最初的目的是为了测试,我发现很难找出是否有任何关于测试 Tcl/Tk 本身的命中。
有人知道有一个程序可以让我运行 Tcl/Tk 脚本并测试其用户交互以及最终操作吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否具体询问 GUI 测试或可能有或没有 GUI 组件的 Tcl 脚本测试?
Tcl自带tcltest,对于测试tcl脚本非常有用。它允许您指定预期值、标记测试仅在某些平台上运行等。
要测试 GUI,没有明确的答案。 tcl'ers wiki 列出了一些选择。然而,由于 Tcl 是一种脚本语言,因此您可以轻松编写驱动应用程序的脚本,而无需花哨的工具。我过去所做的是创建诸如“press_button”之类的命令(例如:press_button“Open”),它查找具有标签“Open”的按钮并调用其回调。有了Tcl强大的自省能力,这样的事情就变得相当容易了。
唯一真正的问题是在处理 Windows 上的菜单时,因为这些菜单是使用本机控件实现的,因此与它们交互有点困难。
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.