如何测试您的Cocoa GUI? [英] How do you test your Cocoa GUIs?

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

问题描述

我想为我的Cocoa程序的GUI编写一些测试。

I would like to write some tests for the GUI of my Cocoa program.

有没有好的GUI测试框架的Cocoa应用程序?我发现的唯一的是 Squish ,这,在2.400€,是远远超出我的预算...

Is there any good GUI testing framework for Cocoa apps? The only thing I found is Squish, which, at 2.400€, is well beyond my budget…

任何想法?如何测试您的Cocoa GUI?

Any ideas? How do you test your Cocoa GUIs?

推荐答案

这取决于您的意思是 GUI。

It depends on what you mean by "testing Cocoa GUIs."

如果您需要像虚拟用户工具,那么这些是少数&远;你会看到像Squish和茄子的工具。

If you want tools like the old Virtual User tool included with MPW, then those are few & far between; you'll be looking at tools like Squish and Eggplant.

如果您想为应用程式的人机介面撰写单元测试,建议您按照信任,但验证您在信任的方法因为你正在建立正确的连接(根据你的框架),你的用户可以正确地与你的框架交互。这意味着您可以通过验证来完成大多数测试。您的模型和控制器代码已正确连接到您的数据视图。

If you want to write unit tests for your application's human interface, I suggest you follow a "trust, but verify" approach where you trust that as long as you're making the right connections (according to your framework) that your user can interact properly with your framework. That means you can do the majority of your testing by verifying your model and controller code are hooked up to your views correctly.

在我的网络日志,我写了几个例子,如何具体使用Cocoa,一个测试用target-action构建的用户界面,以及测试用Cocoa绑定构建的用户界面。 (记住,当然,这两种技术不是排他的:如果你想在通过Cocoa绑定管理的表视图中进行拖放,你还可以有一个数据源,可能还有一个代理通过target-动作。)

On my weblog, I've written a couple of examples of how to do this specifically with Cocoa, one for testing user interfaces built with target-action, and one for testing user interfaces built with Cocoa bindings. (Remember, of course, that the two technologies aren't exclusive: If you want to do drag & drop in a table view managed via Cocoa bindings, you'd also have a data source and probably a delegate hooked up via target-action.)

我不写单元测试的东西通常是他们的superview中的控件的位置或类型。然而,有时这是重要的获得和保持正确;在这种情况下,我可以查询控件的相应属性,并使用标准断言验证它们。

The thing I don't write unit tests for — generally — is the positioning or type of controls in their superview. Sometimes that is important to get and keep correct, however; in that case, I can just query the appropriate properties of the controls and verify them using the standard assertions.

我真正从不编写代码以模拟事件。我最近遇到的是构建一个假的拖动信息对象,并将其传递到大纲视图数据源,以确保它将正确处理拖动。

What I virtually never do is write code to "simulate events." The closest I've ever come to that is constructing a fake drag info object and passing that to an outline view data source to ensure it will deal with drags correctly.

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

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