Mocking objects with Xcode 7 UI Automation

I was using KIF Framework until now for iOS UI Automation. KIF (also Unit Test) targets runs the Unit/UI testing code in the same process as your application is running and we can easily Mock different objects/classes used by the app to show mock data.

When switching to Xcode 7 based new UI Automation, I found that UI Unit Test target runs in separate process and it launches the application in separate process. And thus it's not possible to access App classes/objects through unit tests and mock them.


Did anyone faced the same issue, and know about any workaround?


Please let me know if any more details are needed.

Answered by Engineer in 85363022

It is true that the process running tests is separate from your application when using UI testing in Xcode. This cannot be changed / worked around.


The XCUIApplication APIs allow you to pass custom environment variables and arguments to your target application. You might be able to use these to control testing specific behavior in your target application.


If there's anything else that you would need/want to do and currently cannot, please describe those needs in new bug reports for us. Thanks!

Accepted Answer

It is true that the process running tests is separate from your application when using UI testing in Xcode. This cannot be changed / worked around.


The XCUIApplication APIs allow you to pass custom environment variables and arguments to your target application. You might be able to use these to control testing specific behavior in your target application.


If there's anything else that you would need/want to do and currently cannot, please describe those needs in new bug reports for us. Thanks!

Mocking objects with Xcode 7 UI Automation
 
 
Q