How to call API of tested app in UI Testing of Xcode7?

Hi guys,


recently I've been investigating new UI Testing in Xcode7. There seems to be limited APIs we can call direct in UI test.

Can I include header files and call public API of my tested app in UI Test? so that I can have more flexibility to set my app status before running test.


I intent to call API method "-(void)reloadURL:(NSURL *)url" of my app in UI Test, but test failed with "XCTRunner -[_XCTRunnerAppDelegate myAppDelegateUtils]: unrecoginzed selector sent to instance 0x7cf0a992fe10"


In Unit Test we can call any API of the tested app, does it support in UI Testing too? I'm a start learner of Xcode and its testing...could anyone help to answer this question? Thanks!

I'm also trying to call some code directly of the app-under-test. Although, it is not possible to directly call code of the app, as the app itself and the testing-app run in two different processes.


It is possible to communicate between the two processes by using sockets. I'm using CocoaAsyncSocket (search on GitHub) to setup a server-socket in the test-app and a client-socket in the app-under-test. The code that has to be called in the app-under-test is wrapped in some helper-classes and are triggered by commands the server sends to the client.

Thank you Hendrikvp! I'll have a try later. During investigations, I found another blog which might be helpful for interaction between app-under-test and UI Testing. http://www.adamkaump.com/thoughts/uitests

I had a UI test case that needed to use a function that was defined in my application. Since there was only a single function, I just added the UITest target as a target for the file that contained the definition. If I had more than one function, I would have created a file with all of the functions that a UI Test might need.

How to call API of tested app in UI Testing of Xcode7?
 
 
Q