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

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

问题描述

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

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

Cocoa 应用有什么好的 GUI 测试框架吗?我唯一发现的是 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?

推荐答案

这取决于您所说的测试 Cocoa GUI"是什么意思.

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

如果你想要像旧的工具 Virtual User 工具,那么这些工具很少&相距甚远;你会看到像 Squish 和 Eggplant 这样的工具.

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.

如果您想为应用程序的人机界面编写单元测试,我建议您遵循trust, but verify" 方法,你信任只要你建立了正确的联系(根据你的框架) 您的用户可以与您的框架正确交互.这意味着您可以通过验证您的模型和控制器代码是否正确连接到您的视图来完成大部分测试.

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 绑定管理的表视图中进行拖放操作,您还需要一个数据源,并且可能还有一个通过目标连接的委托——行动.)

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.)

我不编写单元测试的东西——通常是——它们的父视图中控件的定位或类型.然而,有时获得并保持正确很重要;在这种情况下,我可以查询控件的适当属性并使用标准断言验证它们.

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天全站免登陆