UPDATE
这个问题是几年前写的,UI测试从那以后已经走了很长的路.使用UI自动化仍然是一个选择,但KIF Framework是现在功能测试的更好的解决方案,IMO.
从KIF的github页面:
KIF,which stands for Keep It Functional,is an iOS integration test
framework. It allows for easy automation of iOS apps by leveraging the
accessibility attributes that the OS makes available for those with
visual disabilities.KIF builds and performs the tests using a standard XCTest testing
target. Testing is conducted synchronously in the main thread (running
the run loop to force the passage of time) allowing for more complex
logic and composition. This also allows KIF to take advantage of the
Xcode 5 Test Navigator,command line build tools,and Bot test
reports.
解决方法
苹果在WWDC 2010会议306的视频(“用仪器自动化用户界面测试”)中为该工具提供了一个很好的介绍.我演示了如何在视频中设置脚本并在我的高级iOS开发课程on iTunes U的“测试”会话中进行测试.我可以在here中找到我从该课程中介绍的UI Automation的注释,包括示例脚本.
此外,您可能需要查看James Turner的文章“How to use UIAutomation to create iPhone UI tests”和Alex Vollmer的“Working with UIAutomation”.