2

嗨自动化/iOS专家,

我们最近推出了一个新的 iPhone 应用程序项目,并希望使用 Apple 的 UIAutomation Instruments 自动化一些基本的验收测试。现在我们有一个非常基本的框架来完成这项任务。该框架简单地将Apple提供的底层JS函数封装在Java中(提供一些调试能力),并通过Junit驱动测试。测试在 iPhone 模拟器中运行。

所以背景是 Instruments + Eclipse + Java + Junit + iPhone Simulator。

在编写测试时,我发现测试受应用程序“状态”的影响很大。例如,该应用程序在首次运行时会显示某种“使用条款”页面,但在 iPhone 模拟器重置之前不会再次显示。用户接受“使用条款”后,将被带到“主页”页面,她可以在其中输入一些搜索条件并点击“搜索”并进入搜索结果页面。然后她可以被带到“查看详细信息”页面。

TOU -> 首页 -> 搜索结果 -> 查看详情。

请记住,这只是我真实应用程序的一个非常简化的版本。

现在问题来了:为了自动测试视图细节功能,我的测试是否应该通过前面的所有步骤(假设应用程序总是重新启动而没有保存任何状态)?或者我的测试应该假设一些先决条件(比如假设我的应用程序位于“搜索结果”中的“查看详细信息”测试)?

请说出你的理由。对不起,如果我的英语不是我的母语,很难理解。

谢谢!

文斯

4

1 回答 1

0

"Pre-conditions" / "known baseline" / "known state" are golden for automation. Even more so for UI testing since they have more variations that can cause test failures for issues unrelated to what your test was doing.

So from an automation perspective - go directly to the 'View Detail' test. The majority of your automated test scripts will be in those types of functional areas. TOU, etc. are one-time per reset/install. So two options:

  1. First run an automated script to clear the TOU and exit, followed by all other tests that deal with home page, searching, etc. Or...
  2. Clear the TOU manually, followed by all other tests.
  3. Bonus option: you could also test that the TOU doesn't appear more than once per reset, since it shouldn't. That could be first and second test you always run each time. Then run the remaining tests.

If your automated always rely on the TOU appearing, then after the first test, the others will fail since the TOU won't appear until the next reset/test cycle. You could put a 'handler' at the start of all your automated tests to conditionally manage the TOU page. In this situation, I would go with option #1 above.

于 2012-07-24T10:12:38.473 回答