avalon-events_Avalon-CLI307:自动化的UI测试

avalon-events

avalon-events

If you've ever written a complex Windows UI you may have thought about ways to automate testing of these frameworks.  It was easier in the old days, when every control had a Window Handle that you could get ahold of.  Then more and more controls were owner draw, painted or just magic.  Regardless, automated UI testing is a hassle.

如果您曾经编写过复杂的Windows UI,则可能已经考虑过自动测试这些框架的方法。 在过去,当每个控件都有一个可以使用的Window Handle时,这会更容易。 然后越来越多的控件是所有者绘制,绘画或魔术。 无论如何,自动化的UI测试都很麻烦。

In the last few years I've been all over NUnit.  Just as my dentist says “if you don't floss, don't bother brushing,“ I say, “if you don't Unit Test, don't bother coding.“  But the exception is usually UI.

在过去的几年中,我遍历了NUnit。 就像我的牙医说:“如果不使用牙线,就不用刷牙了,”我说,“如果不进行单元测试,就不用理会编码了。”但通常是UI例外。

I'm in a talk on Avalon's Automated UI Testing Framework.

我正在谈论Avalon的自动UI测试框架。

The Avalon UI Testing Framework appears to expose the UI components as an Object Model, that they are calling “Control Patterns” that expose the behavior of the controls.

Avalon UI测试框架似乎将UI组件作为对象模型公开,它们被称为“控件模式”,以公开控件的行为。

He's brought a Command Prompt up.  He brought up the Windows Device Manager and clicked on it.

他带来了命令提示符。 他调出Windows设备管理器并单击它。

The Command Prompt then displays:

然后,命令提示符将显示:

[Tree View] [Has Children]Patterns = I:Selection

[树状视图] [有孩子]模式= I:选择

then he types “children” and the Device Manager tree expands.

然后他输入“ children”,“设备管理器”树将展开。

The Command Prompt says:

命令提示符说:

Patterns - I:Invoke, IHierarchyItem. I:ExpandCollapse. I:SelectionItem

模式-I:调用,IHierarchyItem。 I:展开崩溃。 I:SelectionItem

he also checks out a Combo Box and it says

他还签出了一个组合框,上面写着

Patterns - I:ExpandCollapse.

模式-I:展开折叠。

This means that rather than exposing the controls directly to the UI Testing code, it exposes the BEHAVIOR.  So, in OOP terms, a ComboBox and a Tree Control both implement “ExpandCollapse.”  But it's not that simplistic.  It's really about behavior.

这意味着,与其直接将控件公开给UI测试代码,不如将其公开为BEHAVIOR。 因此,以OOP术语来说,ComboBox和Tree Control都实现了“ ExpandCollapse”。 但这不是那么简单。 这实际上与行为有关。

Think about this:  If you were using a 3rd party control, you'd have to use that library's proprietary APIs to manipulate it.  With the Windows UI Automation framework the publisher of that control will expose behaviors.  If it's a funky Outlook Bar, perhaps it exposes ExpandCollapse also. 

想想看:如果您使用的是第三方控件,则必须使用该库的专有API对其进行操作。 使用Windows UI自动化框架,该控件的发布者将公开行为。 如果它是一个时髦的Outlook栏,则可能还会公开ExpandCollapse。

You can query these controls for their behavior, ala “Reflection.”  Makes me think of how cool it was 8 or so years ago when I saw Spy++.  Except rather than presenting a physical “tree” this framework presents a logical, practical tree.  (The guy in front of me works for Infragistics.  I can only guess what awesome UI Controls they are going to build.  They kick much tush.)

您可以查询这些控件的行为,例如“反射”。 让我想起八年前左右,当我看到Spy ++时有多酷。 除了提供物理“树”之外,该框架还提供逻辑,实用的树。 (我前面的那个人是为Infragistics工作的。我只能猜测他们将要构建什么很棒的UI控件。它们大受鼓舞。 )

The namespaces (alpha) are MSAvalong.Windows.Automation.  This framework supports ALL LEGACY controls, including VB, WinForms, Win32, etc.  There is also a complete Security Model so your testing software can't be used by the powers of darkness like .VBS files.

命名空间(alpha)是MSAvalong.Windows.Automation。 这个框架支持所有的LEGACY控件,包括VB,WinForms,Win32等。还有一个完整的安全模型,因此您的测试软件不能被.VBS文件之类的强大功能所使用。

Along with this Logical Tree, you get all Properties, Events, Control Patterns and all Input (Mouse, Pen, Keyboard, etc).  Plus, it supports filtering, so you don't get messages shouting at you.

连同此逻辑树,您将获得所有属性,事件,控制模式和所有输入(鼠标,笔,键盘等)。 此外,它还支持过滤功能,因此您不会收到任何消息。

Rather than using the Class Name (and there are thousands) to identify a control and switch on how to test it, you think about the essense of the control and it's behavior.  For example, if you're testing software doesn't know what a control is, it asks it and hears “Oh, you're clickable? And expandable?” and you write tests appropriately.

与其使用类名(有成千上万个)来标识控件并打开如何对其进行测试,不如考虑控件本质及其行为。 例如,如果您要测试的软件不知道控件是什么,它将询问并听到“哦,您可单击吗? 可以扩展吗?” 然后适当地编写测试。

(Awesome, he was just going to start a demo, but the screen saver locked his machine.  He can't remember the password...right now we're looking at a Longhorn security screen as he tries to log in...ouch...I know what this feels like.  He's going to reboot. Oy.)

(太棒了,他只是要开始演示,但是屏幕保护程序锁定了他的机器。他不记得密码了。。。现在我们正在查看Longhorn安全屏幕,因为他试图登录...恩...我知道这是什么感觉。他要重新启动。

翻译自: https://www.hanselman.com/blog/avalon-cli307-automated-ui-testing

avalon-events

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值