Xcode 7 UI test cases for pre Xcode 7 projects

3.1k views Asked by At

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

There are 3 answers

1
Gerd Castan On

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.

0
Gautam Jain On

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

0
Arjun Kalidas On

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.