9

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?

bneely
  • 9,083
  • 4
  • 38
  • 46
Gerd Castan
  • 6,275
  • 3
  • 44
  • 89
  • 1
    Try to search under File > New – A-Live Jun 17 '15 at 08:53
  • 2
    Ok: File > New > Target > Test > Cocoa Touch UI Testing Bundle seems to work at first glance. Thanks for the hint :-) – Gerd Castan Jun 17 '15 at 09:45
  • 1
    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 Jun 17 '15 at 14:44

3 Answers3

13

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.

Gerd Castan
  • 6,275
  • 3
  • 44
  • 89
  • Agreed it's very important to rebuild the project after restarting XCode. I tried all the incremental steps along the way. – Rob Fagen Oct 15 '15 at 22:27
4

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.

Arjun Kalidas
  • 919
  • 9
  • 14
-1

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

Gautam Jain
  • 2,913
  • 30
  • 25