Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Record button disabled in Xcode UI Test Target

I know similar questions have been posted, but from my investigating, there has not been a solution posted, at least not one that works. I have successfully run UI tests only from sample projects in both Swift and Obj-C.

I am trying (unsuccessfully) to integrate UI tests into an existing Xcode Obj-C project, which seems to be another issue altogether. Here are the steps I have taken:

  1. Created a new UI Test target within my project
  2. Ensured that 'Enable Testability' has been set to YES for the target I am testing
  3. Cleaned, cleaned build folder, rebuilt the app, restarted Xcode and everything else I could think of.

When I do this, the test target is available but the record button is greyed out (disabled) and there are no play buttons in the gutter to execute the tests. There is nothing visual about the test class that would indicate that it is a test class. When I place my cursor in the test method, the record button remains disabled.

Is there anything I've left out? Anything else to check that might be preventing UI tests?

like image 504
Pheepster Avatar asked Jan 20 '16 20:01

Pheepster


People also ask

How do I run a UI test in Xcode?

If you are making a new app, make sure you select the “Use UI Tests” checkbox when creating a new Xcode project. To add it in an existing project go to the build folder and on the bottom left you will see the plus button. Selecting that will give you a dropdown menu, where you can then select “UI Testing Bundle”.

What is XCTest XCUITest?

XCTest and XCUITest are integrated with XCode and support writing of test suites with subclasses, methods, and assertions. Tests are run directly from Xcode and are written with either Swift or Objective C.


1 Answers

  1. Record button only gets enabled within a function body.

  2. The function name must start with test. Like testExample().

  3. After changing the name of the function wait for a few seconds for the run icon to appear in the gutter.

Now the record button should appear.

like image 195
Domnic Francis Avatar answered Oct 18 '22 13:10

Domnic Francis