6

Has anyone seen this happen before? I can not run UITests because the button is disabled. I have not found any help online. I have deleted and added a new test target, restarted Xcode and deleted derived data. None of these worked and I have no idea what to try next.

bneely
  • 9,083
  • 4
  • 38
  • 46
Abbey Jackson
  • 885
  • 10
  • 20

8 Answers8

11
You have to create a new target in your project.
Steps:
1) File > New > Target
2) Select in left box: iOS > Test
3) In right box: iOS UI Testing Bundle
4) Run your aplication
5) Record your actions
6) Make assertions
emilianoeloi
  • 554
  • 4
  • 11
  • 1
    I'm not entirely sure what the problem was. I think a bit of a derived data bug. A few days later after rebooting my macbook this was working again. No other changes made. I'm going to accept your answer because in most situations that is exactly the cause of a greyed out button :) – Abbey Jackson Jan 22 '16 at 00:09
3

Another possible cause could be that the UI testing target was not build/run successfully.

Go to Product > Test and make sure no errors. You should also see the test cases in the Test Navigator (if you don't see, then it is not recognised).

samwize
  • 25,675
  • 15
  • 141
  • 186
2

I had the same issue and finally found a solution.

  1. Write a new UI test in a file which is linked to the UI test target.
  2. In the new test write XCTFail("") (which will fail the test)
  3. Run your UI tests and they should fail.
  4. Remove XCTFail("") you added and the red button is now enabled.
harmeet07
  • 501
  • 1
  • 5
  • 11
1

For me it was Deleting ~/Library/Developer/Xcode/DerivedData/ as above, and letting Xcode reindex the project, but I had to make sure to not interrupt the index. Indexing took a while, and if its interrupted, it seems to not pick pack up where it left off. At least for XCUITest targets.

Joe Daniels
  • 1,646
  • 1
  • 11
  • 9
0

Try to delete ~/Library/Developer/Xcode/DerivedData/ and let xcode to reindex your project. This should do the trick

tumultous_rooster
  • 12,150
  • 32
  • 92
  • 149
Stas
  • 41
  • 4
0

Make sure the name of the UI Test file is the same as its class.

StackUnderflow
  • 2,403
  • 2
  • 21
  • 28
0

I just fixed this by commenting out a failing test in my test class. Ran the test so it's green, and then put my cursor on a new line (below commented out test), and the Record button is red again.

You can have other failing tests in your app, but not in the file that is active in Xcode.

In Xcode 9.0

Anna Billstrom
  • 2,482
  • 25
  • 33
0

Click inside test function. You should select test method first. Usually when the button is not active, that means that xcode does not know which test to rec.