如何测试 Tcl/Tk 脚本? [英] How to test a Tcl/Tk script?

查看:34
本文介绍了如何测试 Tcl/Tk 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一些 Tcl/Tk 脚本(因为我们使用的 GUI 只能在 Tcl 中合并宏).我刚刚修改了其中之一,并想对其进行测试.

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.

我们使用 Test::More 来测试 Perl 模块,并在网页上使用了一点 Selenium,但我们从来没有为我们的 Tcl/Tk 脚本提供任何类型的自动测试设备.

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.

我试过搜索,但因为 Tcl 的最初目的是为了测试,我发现很难找出是否有任何关于测试 Tcl/Tk 本身的命中.

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.

有谁知道一个程序可以让我运行 Tcl/Tk 脚本,并测试它的用户交互以及它的最终操作?

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?

推荐答案

您是专门询问 GUI 测试,还是测试可能有也可能没有 GUI 组件的 Tcl 脚本?

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

Tcl 带有 tcltest,这对于测试 tcl 脚本.它允许您指定预期值、标记测试仅在某些平台上运行等.

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.

要测试 GUI,没有明确的答案.tcl'ers wiki 列出了一些选择.但是,由于 Tcl 是一种脚本语言,您可以轻松编写驱动应用程序的脚本,而无需花哨的工具.我过去所做的是创建诸如press_button"之类的命令(例如:press_buttonOpen"),它会查找具有标签Open"的按钮并调用其回调.有了 Tcl 强大的自省能力,这样的事情就变得很容易了.

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.

唯一真正的问题是在处理 Windows 上的菜单时,因为这些是使用本机控件实现的,因此与它们交互有点困难.

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.

这篇关于如何测试 Tcl/Tk 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆