xcode7xcode-ui-testingfastlane

Accessing project files from Xcode UI Test Target


I created a new UI Test Target to try out the new Xcode 7 UI tests. Aside from recording some steps, I also want to run some of my code inside the tests such as Utils class to test for some cases etc and take different paths in the test.

Is there a way to make all my project files and libraries included in this new UI Test Target ? I can make sure that my source files are include this UI Test Target from the Target Membership checkbox but that would mean that I would have to go through all my files and manually check that box?

Also, how does it work with the UIKit Framework? I need my tests to be able to find UIScreen class for instance.


Solution

  • Using the new UI automation framework Apple introduced in WWDC 15 it is not possible to access your app's code from the UI-Automation test. It's meant to simulate what a user would have access too, which can be frustrating at times.

    The UI tests are a separate module from the app, therefore not run inside your app as a logic test would. The only way for them to share code is to compile in all the app files you need to share between the two modules. Hope that helps.