Xcode 7 UI Tests, Recording button is greyed out

12,089

Solution 1

FWIW: I had this problem and it turns out I was trying to run the simulator in the wrong OS.

I was trying to use iOS 8, and UITesting only works in iOS 9+.

Switch the simulator version, and the record button appears.

Solution 2

To enable the red button, you have to have the cursor on the test method:

enter image description here

Solution 3

I got stuck on this for a while too. In order to record, you have to be in a class that Xcode recognizes as containing tests. Add a file to your UI testing target with something like:

import Foundation
import XCTest

class MyTests: XCTestCase {
    func testSomething() {

    }
}

Save the file, clean your project, and switch to another file then back to this one. Record button should be available then.

Solution 4

I had the same issue and my setup was correct, iOS >= 9.0, target was added.

The problem was Xcode indexing which took for a while (about 1h), after indexing was done, recording button becomes active.

Solution 5

Had the same issue on Xcode 8.3.

I have removed the tearDown method

   override func tearDown() {
        super.tearDown()

    }

As didn't need to use it. As soon as I added it back the record button was enabled.

Share:
12,089
rustylepord
Author by

rustylepord

Updated on June 22, 2022

Comments

  • rustylepord
    rustylepord about 2 years

    I am trying to add UI tests to my existing project using Xcode 7. However the UI test recording button is always greyed out. What I am missing here?

    I tried restarting Xcode, cleaning and rebuilding the project and adding a new UI test target. Does anyone else experience the same behaviour?

  • rustylepord
    rustylepord almost 9 years
    Thanks @Maldron , I did this several times but didn't work out. Had to readd the UI test target again. Feels like UI tests are really buggy.
  • Apophenia Overload
    Apophenia Overload almost 9 years
    Sometimes Xcode bugs out and doesn't recognize a test case as an actual test case (you aren't able to play it either, because the option is missing in the bar to the left of the method declaration. I mostly get over them by alternately restarting Xcode, and disconnecting and/or restarting the simulator or attached test device. Haven't had to restart my machine, at least!
  • Lisarien
    Lisarien over 8 years
    By restarting Xcode has resolved the issue for me. Thanks
  • smac89
    smac89 over 8 years
    The fixes to Apple's problems...simply amazing!
  • earnshavian
    earnshavian about 8 years
    This appears to be the correct answer to this question for newly created UI test targets. My indexing took over 20 minutes after which the button was available.
  • iCyberPaul
    iCyberPaul about 8 years
    I made this process quicker by quitting Xcode and relaunching Xcode again. As soon as it had finished processing and I updated the cursor position the record button became available.
  • kuzdu
    kuzdu about 8 years
    I have to click onto the square right the testSomething() function. This worked for me
  • Morgz
    Morgz almost 8 years
    Waiting for indexing to finish fixed my problem.
  • Rob Norback
    Rob Norback about 7 years
    Just an addition, my cursor had to be inside a function that started with the keyword test in my UITest file in order to get the record button to show.
  • Stamp
    Stamp almost 7 years
    Agreement with the above comments... physically selecting on or inside the testExample() function with the cursor enabled the button... maybe this is just my ignorance on how these tests work.
  • mehdi
    mehdi over 5 years
    the test function needs to be started with "test" and there must be at least comment line inside it.
  • khalid
    khalid over 5 years
    you are right, i tested all this solutions and the only that solve me is your answer, thanks
  • hellaandrew
    hellaandrew about 5 years
    Yea.. I guess Xcode needed to refresh some internal state which happens after selecting a different file.
  • crgt
    crgt over 4 years
    THANK YOU VERY MUCH
  • Blake
    Blake over 4 years
    Thank you! I actually had to create a new scheme because a new scheme wasn't automatically created when I created a new test target.