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:
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?
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”.
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.
Record button only gets enabled within a function body.
The function name must start with test
. Like testExample()
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With