9
votes

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?

3
Try to search under File > New - A-Live
Ok: File > New > Target > Test > Cocoa Touch UI Testing Bundle seems to work at first glance. Thanks for the hint :-) - Gerd Castan
creating a new UI test target seems to be not enough for an existing project. In a newly created project I can record a UI test via the red dot. When I add a UI test target to an existing project, the red dot is pale and does not work. No error message. - Gerd Castan

3 Answers

13
votes

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.

4
votes

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.

-1
votes

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