Xcode 7 UI test cases for pre Xcode 7 projects

北城余情 提交于 2020-01-02 01:23:07

问题


Apple simplified iOS UI testing in Xcode 7.

With new Xcode 7 projects, all you have to do to get the complete configuration for iOS UI testing is to check "Include UI tests" when creating a project.

What are the steps to get the same in Xcode 7 for projects that were created before Xcode 7 existed?


回答1:


After testing several older projects:

Adding a new UI test target is sufficient as suggested by a-live in a comment to the question:

File > New > Target > Test > Cocoa Touch UI Testing Bundle

With Xcode 7 beta1, all of my projects habe been unstable after adding this target with different symptoms:

  • Compiler not able to import XCTest
  • red recording button greyed out and not working (even with cursor in the method)
  • Xcode crashing after pressing record button

Most problems were fixed after rebuilding the project, exiting XCode, restarting XCode with the project, rebuilding again. All were fixed after repeating this.




回答2:


New UI testing framework requires your simulator running on iOS version 9.0. I encountered the issue of recording button being disabled for version below 9.0, like 8.4 etc.




回答3:


The steps to add UI tests to an old project are also the same. Add a UI Testing bundle as suggested by Gerd, above. Then:

  • Take the cursor to a method in the .m test file.

  • When you take the cursor there, you will see the record button is enabled, which is on the top of the debug console.

  • Press record. This will start up your simulator and start writing code as per your actions.

You can find detailed steps here - https://krausefx.com/blog/run-xcode-7-ui-tests-from-the-command-line



来源:https://stackoverflow.com/questions/30886525/xcode-7-ui-test-cases-for-pre-xcode-7-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!