Xcode 7 UI Tests, Recording button is greyed out
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:
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.
rustylepord
Updated on June 22, 2022Comments
-
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 almost 9 yearsThanks @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 almost 9 yearsSometimes 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 over 8 yearsBy restarting Xcode has resolved the issue for me. Thanks
-
smac89 over 8 yearsThe fixes to Apple's problems...simply amazing!
-
earnshavian about 8 yearsThis 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 about 8 yearsI 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 about 8 yearsI have to click onto the square right the testSomething() function. This worked for me
-
Morgz almost 8 yearsWaiting for indexing to finish fixed my problem.
-
Rob Norback about 7 yearsJust 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 almost 7 yearsAgreement 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 over 5 yearsthe test function needs to be started with "test" and there must be at least comment line inside it.
-
khalid over 5 yearsyou are right, i tested all this solutions and the only that solve me is your answer, thanks
-
hellaandrew about 5 yearsYea.. I guess Xcode needed to refresh some internal state which happens after selecting a different file.
-
crgt over 4 yearsTHANK YOU VERY MUCH
-
Blake over 4 yearsThank you! I actually had to create a new scheme because a new scheme wasn't automatically created when I created a new test target.